Repository navigation
Commit 3fa2904
committed
fix: require end of input when parsing a single statement
- `Statement()` lost its `<EOF>` validation in 063d244 ("feat: return any `UnsupportedStatement`
content"), which replaced `[ <ST_SEMICOLON> ] <EOF>` with `( <ST_SEMICOLON> | <EOF> )`; ever
since, input holding more than one statement silently returned a truncated AST instead of
failing, so callers such as PageHelper's count SQL parser reuse the full parameter mappings
against a partial statement
- `ST_SEMICOLON` also matches blank line runs such as `"\n\n\n"`, which makes the silent
truncation reachable from ordinary formatted SQL that has no semicolon at all
- restore the pre-063d2442 contract with `( <ST_SEMICOLON> )* <EOF>` in both `Statement()`
branches, keeping trailing separators and comments legal while rejecting any unconsumed
statement
- `Statements()` (which kept its trailing `<EOF>`) and `SingleStatement()` are untouched; walking
a script statement by statement stays the incremental API's job
- rewrite the routine boundary test that asserted the lenient behaviour to drive the parser with
`SingleStatement()`, which is how `streamStatements` consumes multi statement scripts1 parent 2b3bebe commit 3fa2904
3 files changed
Lines changed: 39 additions & 4 deletions
File tree
- src
- main/jjtree/net/sf/jsqlparser/parser
- test/java/net/sf/jsqlparser
- parser
- statement/create
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3269 | 3269 | | |
3270 | 3270 | | |
3271 | 3271 | | |
| 3272 | + | |
3272 | 3273 | | |
3273 | 3274 | | |
3274 | 3275 | | |
3275 | 3276 | | |
3276 | 3277 | | |
3277 | 3278 | | |
3278 | | - | |
| 3279 | + | |
3279 | 3280 | | |
3280 | 3281 | | |
3281 | 3282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
528 | 558 | | |
529 | 559 | | |
530 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | | - | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | | - | |
| 118 | + | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| |||
0 commit comments