Repository navigation
Conversation
The DuckDB parser skipped every statement that converted to ast.TODO. The span of a statement includes the comments before it, so a "-- name:" annotation was lost with the statement. sqlc generate exited 0, printed nothing and generated no method for it. Keep skipping a statement that has no query annotation (INSTALL, LOAD and SET in a schema file). Return an error for a statement that has one, and point it at the annotation. Adds analyze_unsupported_statement and a control case, analyze_skipped_schema_statements.
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 #4656
Problem
The DuckDB parser skipped every statement that converted to
ast.TODO. The span of a statement includes the comments before it, so the-- name:annotation was lost with the statement.sqlc generateexited 0, printed nothing, and generated no method for it.Change
In
internal/engine/duckdb/parse.go:INSTALL,LOADandSETin a schema file).query <name>: statement is not supported by the duckdb engine. The error points at the annotation line.The parser now reads its input once (
io.ReadAll) so that the statement offsets index the text.Tests
New end-to-end cases (
sqlc analyze --dialect duckdb):analyze_unsupported_statement/duckdb: an annotatedCOPYafter a valid query. Must fail,stderr.txtcommitted. It fails without the change (exit 0, JSON for one query) and passes with it.analyze_skipped_schema_statements/duckdb: control.INSTALL,LOADandSETin the schema file stay skipped. It passes with and without the change.go test ./internal/endtoend -run TestReplay/base: 971 pass, 58 skip, 0 fail before; 973 pass, 58 skip, 0 fail after. The only difference is the two new cases.go test ./internal/engine/... ./internal/core/... ./internal/compiler/... ./internal/codegen/... ./internal/cmd/... ./internal/metadata/... ./internal/sql/...: all ok.Not run: the
managed-dbcontext,--tags=examples, and theinternal/goldeneyechecks.Notes
The same check does not cover an unsupported expression inside a statement that converts (it is still typed as unknown). Changing that would alter how every unsupported expression is treated, so I left it.