Skip to content

Commit 7f30b96

Browse files
sgielenclaude
andcommitted
Test :iter end to end with PostgreSQL
A case of its own for the stdlib and pgx templates, and an :iter query in the cases for wrap_errors, emit_prepared_queries and emit_methods_with_db_argument, as the other query types have. invalid_queries_foo covers :iter without a RETURNING clause, and the "missing query type" error now lists :iter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 138b1c9 commit 7f30b96

32 files changed

Lines changed: 778 additions & 5 deletions

File tree

‎internal/endtoend/testdata/comment_godoc_db_argument/postgresql/pgx/v4/go/query.sql.go‎

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

‎internal/endtoend/testdata/comment_godoc_db_argument/postgresql/pgx/v4/query.sql‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
-- This function returns a list of Foos
33
SELECT * FROM foo;
44

5+
-- name: IterFoo :iter
6+
-- This function returns an iterator over Foos
7+
SELECT * FROM foo;
8+
59
-- name: OneFoo :one
610
-- This function returns one Foo
711
SELECT * FROM foo;

‎internal/endtoend/testdata/comment_godoc_db_argument/postgresql/pgx/v5/go/query.sql.go‎

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

‎internal/endtoend/testdata/comment_godoc_db_argument/postgresql/pgx/v5/query.sql‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
-- This function returns a list of Foos
33
SELECT * FROM foo;
44

5+
-- name: IterFoo :iter
6+
-- This function returns an iterator over Foos
7+
SELECT * FROM foo;
8+
59
-- name: OneFoo :one
610
-- This function returns one Foo
711
SELECT * FROM foo;

‎internal/endtoend/testdata/invalid_queries_foo/pgx/v4/query.sql‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ INSERT INTO foo (id) VALUES ($1);
1818

1919
-- name: InsertFoo :batchone
2020
INSERT INTO foo (id) VALUES ($1);
21+
22+
-- name: DeleteFooIter :iter
23+
DELETE FROM foo WHERE id = $1;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# package querytest
2-
query.sql:1:1: missing query type [':one', ':many', ':exec', ':execrows', ':execlastid', ':execresult', ':copyfrom', 'batchexec', 'batchmany', 'batchone']: -- name: ListFoos
2+
query.sql:1:1: missing query type [':one', ':many', ':iter', ':exec', ':execrows', ':execlastid', ':execresult', ':copyfrom', 'batchexec', 'batchmany', 'batchone']: -- name: ListFoos
33
query.sql:5:1: invalid query comment: -- name: ListFoos :one :many
44
query.sql:8:1: invalid query type: :two
55
query.sql:11:1: query "DeleteFoo" specifies parameter ":one" without containing a RETURNING clause
66
query.sql:14:1: query "UpdateFoo" specifies parameter ":one" without containing a RETURNING clause
77
query.sql:17:1: query "InsertFoo" specifies parameter ":one" without containing a RETURNING clause
88
query.sql:20:1: query "InsertFoo" specifies parameter ":batchone" without containing a RETURNING clause
9+
query.sql:23:1: query "DeleteFooIter" specifies parameter ":iter" without containing a RETURNING clause

‎internal/endtoend/testdata/invalid_queries_foo/pgx/v5/query.sql‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ INSERT INTO foo (id) VALUES ($1);
1818

1919
-- name: InsertFoo :batchone
2020
INSERT INTO foo (id) VALUES ($1);
21+
22+
-- name: DeleteFooIter :iter
23+
DELETE FROM foo WHERE id = $1;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# package querytest
2-
query.sql:1:1: missing query type [':one', ':many', ':exec', ':execrows', ':execlastid', ':execresult', ':copyfrom', 'batchexec', 'batchmany', 'batchone']: -- name: ListFoos
2+
query.sql:1:1: missing query type [':one', ':many', ':iter', ':exec', ':execrows', ':execlastid', ':execresult', ':copyfrom', 'batchexec', 'batchmany', 'batchone']: -- name: ListFoos
33
query.sql:5:1: invalid query comment: -- name: ListFoos :one :many
44
query.sql:8:1: invalid query type: :two
55
query.sql:11:1: query "DeleteFoo" specifies parameter ":one" without containing a RETURNING clause
66
query.sql:14:1: query "UpdateFoo" specifies parameter ":one" without containing a RETURNING clause
77
query.sql:17:1: query "InsertFoo" specifies parameter ":one" without containing a RETURNING clause
88
query.sql:20:1: query "InsertFoo" specifies parameter ":batchone" without containing a RETURNING clause
9+
query.sql:23:1: query "DeleteFooIter" specifies parameter ":iter" without containing a RETURNING clause

‎internal/endtoend/testdata/invalid_queries_foo/stdlib/query.sql‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ UPDATE foo SET id = $2 WHERE id = $1;
1515

1616
-- name: InsertFoo :one
1717
INSERT INTO foo (id) VALUES ($1);
18+
19+
-- name: DeleteFooIter :iter
20+
DELETE FROM foo WHERE id = $1;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# package querytest
2-
query.sql:1:1: missing query type [':one', ':many', ':exec', ':execrows', ':execlastid', ':execresult', ':copyfrom', 'batchexec', 'batchmany', 'batchone']: -- name: ListFoos
2+
query.sql:1:1: missing query type [':one', ':many', ':iter', ':exec', ':execrows', ':execlastid', ':execresult', ':copyfrom', 'batchexec', 'batchmany', 'batchone']: -- name: ListFoos
33
query.sql:5:1: invalid query comment: -- name: ListFoos :one :many
44
query.sql:8:1: invalid query type: :two
55
query.sql:11:1: query "DeleteFoo" specifies parameter ":one" without containing a RETURNING clause
66
query.sql:14:1: query "UpdateFoo" specifies parameter ":one" without containing a RETURNING clause
7-
query.sql:17:1: query "InsertFoo" specifies parameter ":one" without containing a RETURNING clause
7+
query.sql:17:1: query "InsertFoo" specifies parameter ":one" without containing a RETURNING clause
8+
query.sql:20:1: query "DeleteFooIter" specifies parameter ":iter" without containing a RETURNING clause

0 commit comments

Comments
 (0)