Skip to content

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

Description

@Aias00

Description

OscarIdentifierProcessor.isReservedKeyword looks 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) returns false, violating the SPI contract that every sibling dialect satisfies by uppercasing with Locale.ROOT.

The bug is masked only inside quoteIdentifier (which calls identifier.toUpperCase() before delegating), but any direct SPI caller (completion/metadata paths) gets the wrong answer, so lowercase reserved words would be left unquoted.

Location

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

@Override
public boolean isReservedKeyword(String identifier, Integer majorVersion, Integer minorVersion) {
    return RESERVED_KEYWORDS.contains(identifier);
}

Sibling idiom (DM/SUNDB/XUGUDB all uppercase + null-guard):

return identifier != null && RESERVED_KEYWORDS.contains(identifier.toUpperCase(Locale.ROOT));

Impact

Reserved-keyword identifiers reached via direct isReservedKeyword callers are returned unquoted; inconsistent dialect behavior. Masked in the quoteIdentifier path.

Suggested fix

Match the sibling idiom (uppercase with Locale.ROOT + null guard) and add import java.util.Locale;:

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

Related existing

None. No prior issue covers the Oscar reserved-keyword casing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions