Skip to content

Commit 357d042

Browse files
committed
fix: handle spatial static methods
1 parent bb6f481 commit 357d042

7 files changed

Lines changed: 19211 additions & 18858 deletions

tsql/TSqlParser.g4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4201,6 +4201,7 @@ function_call
42014201
| freetext_function #FREE_TEXT
42024202
| partition_function #PARTITION_FUNC
42034203
| hierarchyid_static_method #HIERARCHYID_METHOD
4204+
| spatial_static_method #SPATIAL_METHOD
42044205
;
42054206

42064207
partition_function
@@ -4733,6 +4734,10 @@ hierarchyid_static_method
47334734
: HIERARCHYID DOUBLE_COLON (GETROOT '(' ')' | PARSE '(' input=expression ')')
47344735
;
47354736

4737+
spatial_static_method
4738+
: (GEOGRAPHY | GEOMETRY) DOUBLE_COLON id_ '(' expression_list_? ')'
4739+
;
4740+
47364741
nodes_method
47374742
: (loc_id=LOCAL_ID | value_id=full_column_name | '(' subquery ')') '.' NODES '(' xquery=STRING ')'
47384743
;
@@ -5541,6 +5546,7 @@ keyword
55415546
| PAGECOUNT
55425547
| PAGLOCK
55435548
| PARAMETERIZATION
5549+
| PARSE
55445550
| PARSENAME
55455551
| PARSEONLY
55465552
| PARTITION

tsql/parser_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,32 @@ func TestDDLIndexParser(t *testing.T) {
124124
require.Equal(t, 0, parserErrors.errors)
125125
}
126126

127+
func TestSpatialStaticMethodsParser(t *testing.T) {
128+
filePath := "examples/spatial_static_methods.sql"
129+
input, err := antlr.NewFileStream(filePath)
130+
require.NoError(t, err)
131+
132+
lexer := tsql.NewTSqlLexer(input)
133+
134+
stream := antlr.NewCommonTokenStream(lexer, 0)
135+
p := tsql.NewTSqlParser(stream)
136+
137+
lexerErrors := &CustomErrorListener{}
138+
lexer.RemoveErrorListeners()
139+
lexer.AddErrorListener(lexerErrors)
140+
141+
parserErrors := &CustomErrorListener{}
142+
p.RemoveErrorListeners()
143+
p.AddErrorListener(parserErrors)
144+
145+
p.BuildParseTrees = true
146+
147+
_ = p.Tsql_file()
148+
149+
require.Equal(t, 0, lexerErrors.errors)
150+
require.Equal(t, 0, parserErrors.errors)
151+
}
152+
127153
func TestSpatialComprehensiveParser(t *testing.T) {
128154
filePath := "examples/spatial_comprehensive.sql"
129155
input, err := antlr.NewFileStream(filePath)

tsql/tsql_parser.go

Lines changed: 19141 additions & 18858 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsql/tsqlparser_base_listener.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsql/tsqlparser_base_visitor.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsql/tsqlparser_listener.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsql/tsqlparser_visitor.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)