Skip to content

Commit 03ea117

Browse files
kyleconroyclaude
andcommitted
fix(testdata): Update SQLite tests for real database analyzer
The SQLite database analyzer now validates queries against real SQLite, revealing several issues in test files: - builtins: Remove sqlite_offset (not available in standard SQLite) - ddl_create_trigger: Add missing tables referenced by trigger - insert_select_invalid: Separate schema from query, update error message - invalid_group_by_reference: Separate schema from query, update error message - invalid_table_alias: Fix INT to INTEGER, separate schema, update error - join_left_same_table: Fix authors.parent_id to a.parent_id (use alias) - limit: Remove UPDATE/DELETE LIMIT (requires special compile option) - quoted_names_complex: Fix UPDATE referencing renamed table - select_exists: Change INT to INTEGER for AUTOINCREMENT - select_not_exists: Fix whitespace, detect parameter - sqlc_embed: Use :memory: for ATTACH, fix u.users.id to u.id Tests with different error messages in base vs managed-db contexts now have exec.json files limiting them to managed-db context only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 49e1ce4 commit 03ea117

File tree

31 files changed

+66
-74
lines changed

31 files changed

+66
-74
lines changed

internal/endtoend/testdata/builtins/sqlite/go/scalarfunc.sql.go

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

internal/endtoend/testdata/builtins/sqlite/queries/scalarfunc.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ SELECT sqlite_compileoption_get(1);
106106
-- name: GetSQLiteCompileOptionUsed :one
107107
SELECT sqlite_compileoption_used(1);
108108

109-
-- name: GetSQLiteOffset :one
110-
SELECT sqlite_offset(1);
111-
112109
-- name: GetSQLiteSourceID :one
113110
SELECT sqlite_source_id();
114111

internal/endtoend/testdata/ddl_create_trigger/sqlite/go/models.go

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

internal/endtoend/testdata/ddl_create_trigger/sqlite/schema.sql

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
/* examples copied from https://www.sqlite.org/lang_createtrigger.html
22
only expectation in sqlc is that they parse, codegen is unaffected */
33

4-
CREATE TRIGGER update_customer_address UPDATE OF address ON customers
4+
CREATE TABLE trigger_customers (
5+
name TEXT PRIMARY KEY,
6+
address TEXT
7+
);
8+
9+
CREATE TABLE trigger_orders (
10+
id INTEGER PRIMARY KEY,
11+
customer_name TEXT,
12+
address TEXT
13+
);
14+
15+
CREATE TRIGGER update_customer_address UPDATE OF address ON trigger_customers
516
BEGIN
6-
UPDATE orders SET address = new.address WHERE customer_name = old.name;
17+
UPDATE trigger_orders SET address = new.address WHERE customer_name = old.name;
718
END;
819

920
CREATE TABLE customer(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"contexts": ["managed-db"]
3+
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
CREATE TABLE foo (bar text);
2-
31
-- name: InsertFoo :exec
42
INSERT INTO foo (bar)
53
SELECT 1, ?, ?;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE TABLE foo (bar text);

internal/endtoend/testdata/insert_select_invalid/sqlite/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"engine": "sqlite",
66
"path": "go",
77
"name": "querytest",
8-
"schema": "query.sql",
8+
"schema": "schema.sql",
99
"queries": "query.sql"
1010
}
1111
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# package querytest
2-
query.sql:4:1: INSERT has more expressions than target columns
2+
query.sql:1:1: sqlite3: SQL logic error: 3 values for 1 columns
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"contexts": ["managed-db"]
3+
}

0 commit comments

Comments
 (0)