Skip to content

Keep an @ inside a quoted table name instead of splitting off a database link - #2976

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:fix/quoted-name-at-sign-20261204
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:fix/quoted-name-at-sign-20261204

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

Table.getName() dropped an Oracle database link by cutting the name at its last @, without looking at quotes. A quoted name containing @ lost everything after it in every dialect: CREATE TABLE `t@x` gave the name `t and the database link x` , and DROP INDEX "idx@x" gave the index name "idx. MySQL, PostgreSQL and SQL Server all allow @ in quoted identifiers.

What changes

  • getName() and getDBLinkName() split only at the last @ outside backticks, double quotes and square brackets. orders@remote is still orders with the link remote, and "a@b"@remote is "a@b" with remote.
  • getDBLinkName() returns null when the name has no database link. It used to return the whole name, so orders had the link orders and the T-SQL table variable @t had the link @t.

Validation

  • New TableTest cases cover quoted names with @ in MySQL, PostgreSQL and SQL Server DDL, an Oracle schema-qualified name with a database link, and names without one. Seven of them fail on master.
  • gradle check and checkGrammarAmbiguity completed with 18,796 tests, 0 failures and no grammar choice conflicts, and mvn verify passed. spotlessJavaCheck and spotlessMiscCheck report CCJSqlParserTest.java and CHANGELOG.md, which fail the same way on master.

Prepared with Claude Code.

Table.getName() cut the name at its last @ to drop an Oracle database link,
as in orders@remote, without looking at quotes. A quoted name with an @ lost
its end in every dialect: CREATE TABLE `t@x` gave the name `t and the
database link x`, and DROP INDEX "idx@x" the index name "idx.

getName() and getDBLinkName() now split at the last @ outside backticks,
double quotes and square brackets. getDBLinkName() returns null for a name
without a database link instead of the whole name.

Signed-off-by: minleejae <mmj9808@gmail.com>

This branch has not been deployed

No deployments
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.

1 participant