Skip to content

Commit b920257

Browse files
committed
compiler: set newParser for the engines main added, and cover hidden columns
Rebasing onto main brought two things this change has to answer for. SQL Server and DuckDB were added to initCore assigning c.parser directly, while this branch had taken to deriving c.parser from c.newParser at the end of the same switch. Neither side conflicted, so the rebase produced a switch that leaves newParser nil for those two engines and then calls it — every SQL Server and DuckDB query set panicked. They set newParser like the rest now. An fts5 table offers columns it does not declare, and a star must not expand to them. The analyzer already skips a hidden column, and the merge carried that into the star's column list along with the result set, which is what it should do. Nothing covered it: the fts5 case selects named columns, and it only runs under the opt-in core context. star_expansion_core selects a star from an fts5 table on sqlite, where it runs in the default suite, and expands to the declared column alone the way the legacy path does. The goldens are regenerated for codegen emitting any over interface{}.
1 parent ff21d6e commit b920257

8 files changed

Lines changed: 82 additions & 11 deletions

File tree

‎internal/compiler/engine.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ func (c *Compiler) initCore() error {
150150
c.selector = newDefaultSelector()
151151
dialect = googlesql.Dialect()
152152
case config.EngineMSSQL:
153-
c.parser = mssql.NewParser()
153+
c.newParser = func() Parser { return mssql.NewParser() }
154154
c.selector = newDefaultSelector()
155155
dialect = mssql.Dialect()
156156
case config.EngineDuckDB:
157-
c.parser = duckdb.NewParser()
157+
c.newParser = func() Parser { return duckdb.NewParser() }
158158
c.selector = newDefaultSelector()
159159
dialect = duckdb.Dialect()
160160
default:

‎internal/endtoend/testdata/star_expansion_core/mysql/go/db.go‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/endtoend/testdata/star_expansion_core/postgresql/go/db.go‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/endtoend/testdata/star_expansion_core/sqlite/go/db.go‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/endtoend/testdata/star_expansion_core/sqlite/go/models.go‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/endtoend/testdata/star_expansion_core/sqlite/go/query.sql.go‎

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/endtoend/testdata/star_expansion_core/sqlite/query.sql‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ INSERT INTO bar (a, c) VALUES (?, ?) RETURNING *;
1818

1919
-- name: StarExpansionAliasedSubquery :many
2020
SELECT (SELECT * FROM baz LIMIT 1) AS x FROM foo GROUP BY x;
21+
22+
-- name: StarExpansionHiddenColumns :many
23+
SELECT * FROM recipes_fts;
24+
25+
-- name: StarExpansionQualifiedHiddenColumns :many
26+
SELECT recipes_fts.* FROM recipes_fts;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
CREATE TABLE foo (a text, b text, "group" text);
22
CREATE TABLE bar (a text, c text);
33
CREATE TABLE baz (z text);
4+
CREATE TABLE recipes (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL);
5+
CREATE VIRTUAL TABLE recipes_fts USING FTS5 (name, content='recipes', content_rowid='id');

0 commit comments

Comments
 (0)