Skip to content

fix(oscar): uppercase identifier in isReservedKeyword before lookup - #2388

Merged
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/oscar-reserved-keyword-case-2385
Aug 3, 2026
Merged

openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/oscar-reserved-keyword-case-2385

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What

OscarIdentifierProcessor.isReservedKeyword looked up the identifier in the all-uppercase RESERVED_KEYWORDS set without uppercasing it first, so a lowercase or mixed-case reserved word (e.g. select, Table) returned false. Direct SPI callers (completion/metadata paths) then left reserved-keyword identifiers unquoted. The bug was masked inside quoteIdentifier (which uppercases before delegating).

Location

chat2db-community-plugins/chat2db-community-oscar/src/main/java/ai/chat2db/plugin/oscar/identifier/OscarIdentifierProcessor.java:27-30

Fix

Match the sibling idiom used by DMIdentifierProcessor, SUNDBIdentifierProcessor, and XugudbIdentifierProcessor: uppercase with Locale.ROOT and guard against null.

@Override
public boolean isReservedKeyword(String identifier, Integer majorVersion, Integer minorVersion) {
    return identifier != null && RESERVED_KEYWORDS.contains(identifier.toUpperCase(Locale.ROOT));
}

(import java.util.Locale; added.)

Verification

  • Sibling implementations (DM/SUNDB/XUGUDB) use the identical expression.
  • OscarIdentifierProcessorTest should still pass; a lowercase reserved word now returns true.

Fixes #2385

🤖 Generated with Claude Code

…tterMind#2385)

isReservedKeyword looked up the identifier in the all-uppercase
RESERVED_KEYWORDS set without uppercasing it first, so a lowercase or
mixed-case reserved word (e.g. 'select', 'Table') returned false, leaving
reserved-keyword identifiers unquoted when reached via direct SPI callers
(completion/metadata paths). The bug was masked inside quoteIdentifier
(which uppercases first). Match the sibling idiom (DM/SUNDB/XUGUDB):
uppercase with Locale.ROOT and guard against null.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: liuhy <liuhongyu@apache.org>
Copilot AI review requested due to automatic review settings August 3, 2026 06:27
@Aias00
Aias00 requested a review from openai0229 as a code owner August 3, 2026 06:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Oscar dialect reserved-keyword detection so isReservedKeyword uppercases identifiers (with Locale.ROOT) before checking the all-uppercase RESERVED_KEYWORDS set, aligning behavior with other dialect processors and preventing unquoted reserved words in direct SPI call paths.

Changes:

  • Add Locale import and uppercase reserved-keyword lookup in OscarIdentifierProcessor.isReservedKeyword.
  • Add a null guard to avoid NPEs on direct calls.

Findings (severity order):

  • chat2db-community-server/chat2db-community-plugins/chat2db-community-oscar/src/main/java/ai/chat2db/plugin/oscar/identifier/OscarIdentifierProcessor.java:29-30 — Test gap: no direct unit test for isReservedKeyword covering lowercase/mixed-case inputs and null (only quoteIdentifier is exercised).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@openai0229 openai0229 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the latest main. Reserved keyword lookup is Locale.ROOT case-insensitive and null-safe; the focused Oscar suite ran 25 tests with 0 failures.

@openai0229
openai0229 merged commit daa6491 into OtterMind:main Aug 3, 2026
16 of 17 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(oscar): isReservedKeyword does not uppercase the identifier before lookup

3 participants