Skip to content

Commit 66c9a14

Browse files
committed
test(sqlite): Multiple upserts on conflict clauses end-to-end tests
1 parent 568ebe5 commit 66c9a14

6 files changed

Lines changed: 209 additions & 0 deletions

File tree

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

Lines changed: 31 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_multiple_conflict/sqlite/go/models.go‎

Lines changed: 16 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_multiple_conflict/sqlite/go/query.sql.go‎

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- name: Upsert :exec
2+
INSERT INTO t (id, name, score) VALUES (?, ?, ?)
3+
ON CONFLICT (id) DO UPDATE SET score = ?
4+
ON CONFLICT (name) DO UPDATE SET created = ?;
5+
6+
-- name: UpsertWhere :exec
7+
INSERT INTO t (id, name, score) VALUES (?, ?, ?)
8+
ON CONFLICT (id) DO UPDATE SET score = ? WHERE score < ?
9+
ON CONFLICT (name) DO UPDATE SET created = ? WHERE score < ?;
10+
11+
-- name: UpsertNothingFirst :exec
12+
INSERT INTO t (id, name, score) VALUES (?, ?, ?)
13+
ON CONFLICT (id) DO NOTHING
14+
ON CONFLICT (name) DO UPDATE SET score = ?;
15+
16+
-- name: UpsertReturning :one
17+
INSERT INTO t (id, name, score) VALUES (?, ?, ?)
18+
ON CONFLICT (id) DO UPDATE SET score = ?
19+
ON CONFLICT (name) DO UPDATE SET created = ?
20+
RETURNING id, created;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- https://github.com/sqlc-dev/sqlc/issues/3440
2+
CREATE TABLE t (
3+
id INTEGER PRIMARY KEY,
4+
name TEXT NOT NULL,
5+
score INTEGER NOT NULL,
6+
created TEXT
7+
);
8+
9+
CREATE UNIQUE INDEX t_name ON t (name);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"engine": "sqlite",
6+
"path": "go",
7+
"name": "querytest",
8+
"schema": "schema.sql",
9+
"queries": "query.sql"
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)