Skip to content

Commit 9007110

Browse files
committed
BREAKING! Remove acceptUnsupportedGrammar option
1 parent 5c9a1ee commit 9007110

5 files changed

Lines changed: 0 additions & 47 deletions

File tree

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff 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

208202
When parsing fails with syntax error, it throws `FormattedSyntaxError` which contains a message like:
209203

src/ParserOptions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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
};

src/parser.pegjs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
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
6766
statement
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
96579655
only_postgres = &{ return isPostgresql(); }
96589656
plpgsql = &{ 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
*/

src/utils/parserState.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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;

test/statement.test.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)