Skip to content

Commit 4c7db80

Browse files
committed
test: add WHERE clause variations to upsert_named_params/sqlite
1 parent 58ebe27 commit 4c7db80

2 files changed

Lines changed: 134 additions & 0 deletions

File tree

internal/endtoend/testdata/upsert_named_params/sqlite/go/query.sql.go

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

internal/endtoend/testdata/upsert_named_params/sqlite/query.sql

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,49 @@ INSERT INTO authors (
1111
name = @name,
1212
bio = sqlc.narg('bio')
1313
RETURNING *;
14+
15+
-- name: UpsertAuthorDoUpdateWhere :one
16+
INSERT INTO authors (
17+
id,
18+
name,
19+
bio
20+
) VALUES (
21+
@id,
22+
@name,
23+
sqlc.narg('bio')
24+
) ON CONFLICT(id) DO UPDATE SET
25+
name = @name,
26+
bio = sqlc.narg('bio')
27+
WHERE excluded.name != @name
28+
RETURNING *;
29+
30+
-- name: UpsertAuthorConflictWhere :one
31+
INSERT INTO authors (
32+
id,
33+
name,
34+
bio
35+
) VALUES (
36+
@id,
37+
@name,
38+
sqlc.narg('bio')
39+
) ON CONFLICT(id) DO UPDATE SET
40+
name = @name,
41+
bio = sqlc.narg('bio')
42+
WHERE excluded.bio != sqlc.narg('bio')
43+
RETURNING *;
44+
45+
-- name: UpsertAuthorBothWhere :one
46+
INSERT INTO authors (
47+
id,
48+
name,
49+
bio
50+
) VALUES (
51+
@id,
52+
@name,
53+
sqlc.narg('bio')
54+
) ON CONFLICT(id) DO UPDATE SET
55+
name = @name,
56+
bio = sqlc.narg('bio')
57+
WHERE excluded.name != @name
58+
AND excluded.bio != sqlc.narg('bio')
59+
RETURNING *;

0 commit comments

Comments
 (0)