Skip to content

Escape ' in generated dbscheme names - #22636

Open
GiangTran-FinX wants to merge 1 commit into
github:mainfrom
GiangTran-FinX:tree-sitter-extractor/escape-single-quote
Open

GiangTran-FinX wants to merge 1 commit into
github:mainfrom
GiangTran-FinX:tree-sitter-extractor/escape-single-quote

Conversation

@GiangTran-FinX

Copy link
Copy Markdown

Problem

escape_name in shared/tree-sitter-extractor/src/node_types.rs maps " to dquote but has no mapping for ', so the character is passed through into the generated dbscheme identifier.

A grammar whose node types contain a bare single quote therefore generates an invalid dbscheme. Lua is one: its string node has ' as a delimiter token, and the generator emits

case @lua_string__.start of
  0 = @lua_string_dquote
| 1 = @lua_string_'

which the dbscheme parser rejects at database creation:

A fatal error occurred: ERROR: token recognition error at: '''
  (lua.dbscheme:501,19-20)

No language in this repository has a bare ' in its node types, which is presumably why this has not come up. I hit it while building an out-of-tree Lua extractor on shared/tree-sitter-extractor.

Change

Adds the squote mapping next to dquote, plus a test covering both string delimiters.

Testing

cargo test in shared/tree-sitter-extractor passes (12 tests), and cargo fmt --check is clean. With this applied, the Lua dbscheme generates and codeql database create --language=lua completes.

`escape_name` maps `"` to `dquote` but leaves `'` untouched, so a grammar whose
node types contain a single quote generates an invalid dbscheme identifier.

Lua hits this: its `string` node has `'` as a delimiter token, and the generator
emits `@lua_string_'`, which the dbscheme parser rejects with

    ERROR: token recognition error at: '''

No shipped language contains a bare `'` in a node type, which is why this has
not surfaced before. Found while building an out-of-tree extractor.

Adds the missing mapping and a test covering both string delimiters.
@GiangTran-FinX
GiangTran-FinX requested a review from a team as a code owner September 21, 2026 10:36
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