Fix #10: double-quote reserved-word field names in read_json_auto STRUCT type#13
Open
piotrszul wants to merge 1 commit into
Open
Fix #10: double-quote reserved-word field names in read_json_auto STRUCT type#13piotrszul wants to merge 1 commit into
piotrszul wants to merge 1 commit into
Conversation
… spec
pathsToSchema emitted FHIR field names unquoted in the read_json_auto
`columns` STRUCT type string. When a field name is a DuckDB reserved
word — e.g. `end` from the FHIR Period type — the generated type spec
(`STRUCT(start JSON, end JSON)`) is unparseable and DuckDB aborts with
"can not be converted to a DuckDB Type".
Always double-quote the identifier (both the root key and struct member
names). This is safe for all names and avoids maintaining a reserved-word
list. Verified in DuckDB 1.5.2 that quoting normal identifiers is
harmless and that the previously-failing Encounter period.start/period.end
view now executes and returns rows.
- src/ddb-sql-builder.js: quote node.value in both emitted forms.
- tests/schema.test.js: add a reserved-word ("end") regression test and
update existing expectations to the quoted output.
All 192 tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10.
Problem
pathsToSchema(src/ddb-sql-builder.js) emitted FHIR field names unquoted in theread_json_autocolumnsSTRUCT type string. When a field name is a DuckDB reserved word — e.g.endfrom the FHIRPeriodtype — the generated spec is unparseable:Fix
Always double-quote the identifier in both emitted forms (root key and struct member):
Always-quoting is safe for all names and avoids maintaining a reserved-word list (the issue's recommended direction). Verified in DuckDB 1.5.2 that quoting normal identifiers is harmless, that quoting works for both the root key and struct members, and that the previously-failing
Encounterperiod.start/period.endview now executes and returns rows instead of aborting.Tests
end) regression test intests/schema.test.js.bun test), including the e2e tests that run realread_json_autoqueries.