Skip to content

fix: reject DELETE statements missing a target table - #2843

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
princejain756:fix-delete-requires-table
Oct 21, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
princejain756:fix-delete-requires-table

Conversation

@princejain756

Copy link
Copy Markdown
Contributor

Summary

DELETE, DELETE FROM, DELETE FROM WHERE ... and DELETE FROM USING ... all parsed successfully. The Delete() grammar's bare-FROM alternative never required a table to follow it, so a Delete with a null table was produced and toString() printed the literal text null:

CCJSqlParserUtil.parse("DELETE FROM WHERE a = 1").toString()
// -> "DELETE FROM null WHERE a = 1"

The production now validates through a requireDeleteSyntax() helper (same pattern as the existing requireAccessSyntax() / requireReplicationSyntax()) that a target table was supplied in one of the three supported positions: before FROM, after FROM, or in the pre-FROM table list. DELETE t, DELETE FROM t and DELETE t1 FROM t1 JOIN t2 keep parsing unchanged.

DELETE, DELETE FROM, DELETE FROM WHERE ... and DELETE FROM USING ...
all parsed successfully into a Delete with a null table, and toString()
then printed the literal text "null" (DELETE FROM null WHERE 1 = 1).
The grammar's bare-FROM alternative never required a table to follow.

The production now validates that a target table was supplied in one
of the three supported positions (before FROM, after FROM, or via the
table list) through a requireDeleteSyntax() helper, matching the
existing requireAccessSyntax()/requireReplicationSyntax() pattern.
@manticore-projects
manticore-projects merged commit 6c5fc6c into JSQLParser:master Oct 21, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

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