@@ -5814,4 +5814,46 @@ orders PIVOT (sum(amount) FOR status IN ('open'))`
58145814 expect ( result . errors ) . toHaveLength ( 0 )
58155815 } )
58165816 } )
5817+
5818+ describe ( "'horizon' and 'step' as non-reserved identifier keywords" , ( ) => {
5819+ it ( "should parse 'horizon' as a table name" , ( ) => {
5820+ const result = parseToAst ( "SELECT * FROM horizon" )
5821+ expect ( result . errors ) . toHaveLength ( 0 )
5822+ const stmt = result . ast [ 0 ] as AST . SelectStatement
5823+ const tableRef = stmt . from ?. [ 0 ] as AST . TableRef
5824+ expect ( ( tableRef . table as AST . QualifiedName ) . parts ) . toEqual ( [ "horizon" ] )
5825+ } )
5826+
5827+ it ( "should parse 'step' as a column name" , ( ) => {
5828+ const result = parseToAst ( "SELECT step FROM trades" )
5829+ expect ( result . errors ) . toHaveLength ( 0 )
5830+ } )
5831+
5832+ it ( "should parse 'horizon' as a column name" , ( ) => {
5833+ const result = parseToAst ( "SELECT horizon FROM trades" )
5834+ expect ( result . errors ) . toHaveLength ( 0 )
5835+ } )
5836+
5837+ it ( "should parse 'step' as a table name" , ( ) => {
5838+ const result = parseToAst ( "SELECT * FROM step" )
5839+ expect ( result . errors ) . toHaveLength ( 0 )
5840+ const stmt = result . ast [ 0 ] as AST . SelectStatement
5841+ const tableRef = stmt . from ?. [ 0 ] as AST . TableRef
5842+ expect ( ( tableRef . table as AST . QualifiedName ) . parts ) . toEqual ( [ "step" ] )
5843+ } )
5844+
5845+ it ( "should round-trip 'horizon' through toSql" , ( ) => {
5846+ const sql = "SELECT * FROM horizon"
5847+ const result = parseToAst ( sql )
5848+ expect ( result . errors ) . toHaveLength ( 0 )
5849+ expect ( toSql ( result . ast [ 0 ] ) ) . toBe ( sql )
5850+ } )
5851+
5852+ it ( "should round-trip 'step' through toSql" , ( ) => {
5853+ const sql = "SELECT step FROM trades"
5854+ const result = parseToAst ( sql )
5855+ expect ( result . errors ) . toHaveLength ( 0 )
5856+ expect ( toSql ( result . ast [ 0 ] ) ) . toBe ( sql )
5857+ } )
5858+ } )
58175859} )
0 commit comments