Skip to content

feat: ForUpdateClause API + multi-table OF clause + ORDER BY after FOR UPDATE#1

Merged
rrobetti merged 1 commit intomasterfrom
copilot/fix-select-for-update-detection
Apr 11, 2026
Merged

feat: ForUpdateClause API + multi-table OF clause + ORDER BY after FOR UPDATE#1
rrobetti merged 1 commit intomasterfrom
copilot/fix-select-for-update-detection

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 11, 2026

JSqlParser failed to parse FOR UPDATE OF t1, t2, t3 (only single table was supported) and FOR UPDATE OF t ORDER BY col (non-standard but valid Oracle ordering). Both caused ParseException at the grammar level.

Changes

New ForUpdateClause class

Container for the full FOR UPDATE state — mode, table list, wait options — surfaced via getForUpdate() on PlainSelect:

PlainSelect ps = (PlainSelect) CCJSqlParserUtil.parse(
    "SELECT * FROM t FOR UPDATE OF a, b.c, d SKIP LOCKED");

ForUpdateClause clause = ps.getForUpdate();
clause.isForUpdate();      // true
clause.getTables();        // [a, b.c, d]
clause.isSkipLocked();     // true

Grammar fix: multi-table OF clause

FOR UPDATE OF t1, t2, t3 now parses correctly. Select.forUpdateTable: Table replaced with forUpdateTables: List<Table>; getForUpdateTable() is retained as a backward-compatible alias returning the first element.

Grammar fix: ORDER BY after FOR UPDATE

Added optional ORDER BY production inside the FOR UPDATE grammar block. A forUpdateBeforeOrderBy flag preserves the original clause ordering in toString() / deparser output so round-trip fidelity is maintained.

Updated deparsers & validators

SelectDeParser and SelectValidator updated to iterate the full table list.

Oracle test coverage

for_update07.sql (multi-table OF) and for_update08.sql (ORDER BY after FOR UPDATE) are now in SpecialOracleTest.EXPECTED_SUCCESSES.

Copilot AI requested a review from rrobetti April 11, 2026 16:26
@rrobetti rrobetti marked this pull request as ready for review April 11, 2026 16:32
@rrobetti rrobetti merged commit 38b62e5 into master Apr 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants