Skip to content

fix: preserve case for pseudo-reserved word identifiers in AST nodes - #273

Open
JonathanPerry651 wants to merge 1 commit into
cloudspannerecosystem:mainfrom
JonathanPerry651:fix/preserve-case-reserved-word-identifiers
Open

JonathanPerry651 wants to merge 1 commit into
cloudspannerecosystem:mainfrom
JonathanPerry651:fix/preserve-case-reserved-word-identifiers

Conversation

@JonathanPerry651

Copy link
Copy Markdown

Fixes #272

Summary

Fixes a regression exposed in v1.26.0 (after adding <GRAPH: "graph"> and other pseudo-reserved tokens in be2c24e, combined with reference validation in 7368ef3) where lowercase identifiers matching pseudo-reserved keywords (such as a table named graph) were uppercased to GRAPH by AST nodes calling AstTreeUtils.tokensToString(...) with the default upperCaseReserved = true.

Changes

  • Pass upperCaseReserved = false when rendering identifier/object-name nodes:
    • ASTtable (CREATE [SEARCH] INDEX ... ON <table>)
    • ASTtable_name (ALTER TABLE <table> ...)
    • ASTtable_interleave_clause (INTERLEAVE IN [PARENT] <table>)
    • ASTindex_interleave_clause (CREATE [SEARCH] INDEX ..., INTERLEAVE IN <table>)
    • ASTforeign_key & ASTcheck_constraint (CONSTRAINT <name>)
    • ASTalter_database_statement (ALTER DATABASE <dbname>)
    • ASTannotation & ASTannotation_param
  • Render ASTrow_deletion_policy_clause from its child AST nodes so function/column names preserve case while INTERVAL ... DAY remains uppercased.
  • Render STRUCT fields in ASTcolumn_type using their child ASTname / ASTcolumn_type nodes so struct field names preserve case while field types remain uppercased.
  • Add regression tests in ddlParserValidation.txt, DdlDiffValidationTest, and DdlDiffTest covering lowercase graph across tables, indexes, search indexes, interleaving, constraints, row deletion policies, STRUCT fields, ALTER TABLE, and ALTER DATABASE.

Verification

  • Ran mvn -B verify --file pom.xml:
    • 298 unit tests passed (10 new tests added)
    • 0 Checkstyle violations (google-checkstyle and licence-header)
    • Spotless check passed
    • ErrorProne clean

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.

v1.26.0 uppercases lowercase pseudo-reserved table/identifier names (e.g., graph), breaking diffs and validation

1 participant