File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,12 +198,6 @@ Parses SQL string and returns the CST tree. Takes the following options:
198198 By default a query like ` SELECT * FROM tbl WHERE id = ? ` will result in parse error.
199199 To fix it, use ` paramTypes: ["?"] ` config option.
200200- ** filename** : ` string ` Name of the SQL file. This is only used for error-reporting.
201- - ** acceptUnsupportedGrammar** : ` boolean ` When enabled, code that would otherwise fail to parse,
202- gets parsed as ` unsupported_grammar_stmt ` node. That will consume all text until the next semicolon.
203- After the semicolon, parsing will resume as normal. This option is primarily intended as a workaround
204- for using the parser with an SQL dialect that's not yet 100% supported.
205-
206- ** Deprecated:** use conditional comments instead (see below).
207201
208202When parsing fails with syntax error, it throws ` FormattedSyntaxError ` which contains a message like:
209203
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ export type ParserOptions = {
2525 includeSpaces ?: boolean ;
2626 includeRange ?: boolean ;
2727 paramTypes ?: ParamType [ ] ;
28- acceptUnsupportedGrammar ?: boolean ;
2928 /** SQL file name, used when reporting syntax errors */
3029 filename ?: string ;
3130} ;
Original file line number Diff line number Diff line change 4040 isPlpgsql ,
4141 hasParamType ,
4242 isEnabledWhitespace ,
43- isAcceptUnsupportedGrammar ,
4443 } from " ./utils/parserState" ;
4544 import { isReservedKeyword , isForbiddenImplicitAliasName } from " ./utils/keywords" ;
4645 import { loc } from " ./utils/loc" ;
@@ -67,7 +66,6 @@ program
6766statement
6867 = non_transaction_statement
6968 / transaction_statement // match BEGIN transaction after BEGIN..END block
70- / & { return isAcceptUnsupportedGrammar (); } x :unsupported_grammar_stmt { return x; }
7169
7270// This is referenced by BEGIN..END blocks of FUNCTION definitions,
7371// which don't allow transactions inside them (specifically it would create a conflict
@@ -9657,13 +9655,6 @@ postgres = &{ return isPostgresql() || isPlpgsql(); } // We're treating PostgreS
96579655only_postgres = & { return isPostgresql (); }
96589656plpgsql = & { return isPlpgsql (); }
96599657
9660- unsupported_grammar_stmt = [^;]+ {
9661- return loc ({
9662- type: " unsupported_grammar_stmt" ,
9663- text: text (),
9664- });
9665- }
9666-
96679658/**
96689659 * Generic keyword rules
96699660 */
Original file line number Diff line number Diff line change @@ -33,6 +33,3 @@ export const isEnabledWhitespace = (ws: Whitespace) =>
3333 ( ws . type === "line_comment" || ws . type === "block_comment" ) ) ||
3434 ( getOptions ( ) . includeNewlines && ws . type === "newline" ) ||
3535 ( getOptions ( ) . includeSpaces && ws . type === "space" ) ;
36-
37- export const isAcceptUnsupportedGrammar = ( ) =>
38- getOptions ( ) . acceptUnsupportedGrammar ;
Original file line number Diff line number Diff line change @@ -38,32 +38,4 @@ describe("statement", () => {
3838 }
3939 ` ) ;
4040 } ) ;
41-
42- describe ( "with acceptUnsupportedGrammar:true" , ( ) => {
43- it ( "does not produce a syntax error" , ( ) => {
44- test ( "INSERT TODAYS PUZZLE 123;" , { acceptUnsupportedGrammar : true } ) ;
45- } ) ;
46-
47- it ( "parses the code into unsupported_grammar_stmt nodes" , ( ) => {
48- expect ( parse ( "INSERT TODAYS PUZZLE 123; WHOOPSIE DAISY;" , { acceptUnsupportedGrammar : true } ) )
49- . toMatchInlineSnapshot ( `
50- {
51- "statements": [
52- {
53- "text": "INSERT TODAYS PUZZLE 123",
54- "type": "unsupported_grammar_stmt",
55- },
56- {
57- "text": "WHOOPSIE DAISY",
58- "type": "unsupported_grammar_stmt",
59- },
60- {
61- "type": "empty",
62- },
63- ],
64- "type": "program",
65- }
66- ` ) ;
67- } ) ;
68- } ) ;
6941} ) ;
You can’t perform that action at this time.
0 commit comments