snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
5
internal/endtoend/testdata/fmt/sqlite/exec.json
vendored
Normal file
5
internal/endtoend/testdata/fmt/sqlite/exec.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"command": "fmt",
|
||||
"args": ["--diff"],
|
||||
"contexts": ["base"]
|
||||
}
|
||||
107
internal/endtoend/testdata/fmt/sqlite/query.sql
vendored
Normal file
107
internal/endtoend/testdata/fmt/sqlite/query.sql
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
-- name: GetAuthor :one
|
||||
select id,name , bio from authors
|
||||
where id = ? limit 1;
|
||||
|
||||
-- name: PickyQuery :many
|
||||
SELECT id, -- the primary key
|
||||
name,
|
||||
-- computed downstream
|
||||
bio
|
||||
FROM authors
|
||||
-- soft-deleted rows are filtered
|
||||
WHERE bio IS NOT NULL
|
||||
AND id > ?;
|
||||
|
||||
-- name: InlineBlock :many
|
||||
SELECT /* inline note */ id, name FROM authors ORDER BY name;
|
||||
|
||||
-- name: ListAuthors :many
|
||||
SELECT id, name, bio FROM authors
|
||||
ORDER BY name;
|
||||
|
||||
-- name: GetEvent :one
|
||||
SELECT "EventName", "order"
|
||||
FROM "Events" WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: CountSigils :one
|
||||
SELECT count(*) FROM authors
|
||||
WHERE id <> @at_param AND id <> :colon_param AND id <> $dollar_param;
|
||||
|
||||
-- name: TopAuthors :many
|
||||
WITH ranked AS (
|
||||
SELECT id, name FROM authors
|
||||
)
|
||||
SELECT * FROM ranked;
|
||||
|
||||
-- name: AddAuthor :exec
|
||||
INSERT INTO authors (name, bio)
|
||||
VALUES (?, ?);
|
||||
|
||||
-- name: MakeScratch :exec
|
||||
CREATE TABLE scratch (
|
||||
id INTEGER NOT NULL,
|
||||
label TEXT
|
||||
);
|
||||
|
||||
-- name: MakeMeasurements :exec
|
||||
CREATE TABLE IF NOT EXISTS measurements (
|
||||
id INTEGER PRIMARY KEY,
|
||||
label VARYING CHARACTER(120),
|
||||
ratio DECIMAL(10,5),
|
||||
note
|
||||
);
|
||||
|
||||
-- name: KeepAutoinc :exec
|
||||
CREATE TABLE counters (id INTEGER PRIMARY KEY AUTOINCREMENT, hits INTEGER DEFAULT 0);
|
||||
|
||||
-- name: CastLabel :one
|
||||
SELECT CAST(bio AS VARYING CHARACTER(120)) FROM authors LIMIT 1;
|
||||
|
||||
-- name: MakeSearchIndex :exec
|
||||
CREATE VIRTUAL TABLE IF NOT EXISTS notes_fts USING fts5(body, tag UNINDEXED, tokenize = 'porter');
|
||||
|
||||
-- name: MakeRecipeIndex :exec
|
||||
CREATE VIRTUAL TABLE recipes_fts USING fts5(
|
||||
name,
|
||||
ingredients
|
||||
);
|
||||
|
||||
-- name: LoginName :one
|
||||
SELECT COALESCE(bio, '') AS login FROM authors WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: SpelledJoins :many
|
||||
SELECT a.id
|
||||
FROM authors AS a
|
||||
INNER JOIN authors AS b ON a.id = b.id
|
||||
LEFT OUTER JOIN authors AS c ON a.id = c.id
|
||||
WHERE a.id != ? AND b.id == ? AND c.id <> ?;
|
||||
|
||||
-- name: CommaJoin :one
|
||||
SELECT count(*) FROM authors AS a, authors AS b WHERE a.id = b.id;
|
||||
|
||||
-- name: PlannerHint :many
|
||||
SELECT a.id FROM authors AS a CROSS JOIN authors AS b;
|
||||
|
||||
-- name: NumberedParams :many
|
||||
SELECT id FROM authors WHERE name = ?2 AND bio = ?1;
|
||||
|
||||
-- name: NewestAndOldest :many
|
||||
SELECT id FROM authors
|
||||
UNION
|
||||
SELECT id FROM authors;
|
||||
|
||||
-- name: QuickUnion :many
|
||||
SELECT id FROM authors UNION ALL SELECT id FROM authors;
|
||||
|
||||
-- name: EnableForeignKeys :exec
|
||||
PRAGMA foreign_keys = 1;
|
||||
|
||||
-- name: UpsertAuthor :exec
|
||||
INSERT INTO authors (id, name)
|
||||
VALUES (?, ?)
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
name = excluded.name
|
||||
WHERE excluded.name <> '';
|
||||
|
||||
-- name: QuickUpsert :exec
|
||||
INSERT INTO authors (id, name) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET name = excluded.name;
|
||||
11
internal/endtoend/testdata/fmt/sqlite/schema.sql
vendored
Normal file
11
internal/endtoend/testdata/fmt/sqlite/schema.sql
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE authors (
|
||||
id integer PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
bio text
|
||||
);
|
||||
|
||||
CREATE TABLE "Events" (
|
||||
id integer PRIMARY KEY,
|
||||
"EventName" text NOT NULL,
|
||||
"order" integer NOT NULL
|
||||
);
|
||||
9
internal/endtoend/testdata/fmt/sqlite/sqlc.yaml
vendored
Normal file
9
internal/endtoend/testdata/fmt/sqlite/sqlc.yaml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "sqlite"
|
||||
schema: "schema.sql"
|
||||
queries: "query.sql"
|
||||
gen:
|
||||
go:
|
||||
package: "querytest"
|
||||
out: "go"
|
||||
84
internal/endtoend/testdata/fmt/sqlite/stdout.txt
vendored
Normal file
84
internal/endtoend/testdata/fmt/sqlite/stdout.txt
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
--- a/query.sql
|
||||
+++ b/query.sql
|
||||
@@ -1,12 +1,15 @@
|
||||
-- name: GetAuthor :one
|
||||
+SELECT id, name, bio
|
||||
+FROM authors
|
||||
+WHERE id = ?
|
||||
+LIMIT 1;
|
||||
-select id,name , bio from authors
|
||||
-where id = ? limit 1;
|
||||
|
||||
-- name: PickyQuery :many
|
||||
+SELECT
|
||||
+ id, -- the primary key
|
||||
+ name,
|
||||
+ -- computed downstream
|
||||
+ bio
|
||||
-SELECT id, -- the primary key
|
||||
- name,
|
||||
- -- computed downstream
|
||||
- bio
|
||||
FROM authors
|
||||
-- soft-deleted rows are filtered
|
||||
WHERE bio IS NOT NULL
|
||||
@@ -16,7 +19,8 @@
|
||||
SELECT /* inline note */ id, name FROM authors ORDER BY name;
|
||||
|
||||
-- name: ListAuthors :many
|
||||
+SELECT id, name, bio
|
||||
+FROM authors
|
||||
-SELECT id, name, bio FROM authors
|
||||
ORDER BY name;
|
||||
|
||||
-- name: GetEvent :one
|
||||
@@ -23,8 +27,11 @@
|
||||
SELECT "EventName", "order"
|
||||
+FROM "Events"
|
||||
+WHERE id = ?
|
||||
+LIMIT 1;
|
||||
-FROM "Events" WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: CountSigils :one
|
||||
+SELECT count(*)
|
||||
+FROM authors
|
||||
-SELECT count(*) FROM authors
|
||||
WHERE id <> @at_param AND id <> :colon_param AND id <> $dollar_param;
|
||||
|
||||
-- name: TopAuthors :many
|
||||
@@ -46,7 +53,7 @@
|
||||
-- name: MakeMeasurements :exec
|
||||
CREATE TABLE IF NOT EXISTS measurements (
|
||||
id INTEGER PRIMARY KEY,
|
||||
+ label VARYING CHARACTER(120),
|
||||
- label VARYING CHARACTER(120),
|
||||
ratio DECIMAL(10,5),
|
||||
note
|
||||
);
|
||||
@@ -58,7 +65,7 @@
|
||||
SELECT CAST(bio AS VARYING CHARACTER(120)) FROM authors LIMIT 1;
|
||||
|
||||
-- name: MakeSearchIndex :exec
|
||||
+CREATE VIRTUAL TABLE IF NOT EXISTS notes_fts USING fts5(body, tag UNINDEXED, tokenize = 'porter');
|
||||
-CREATE VIRTUAL TABLE IF NOT EXISTS notes_fts USING fts5(body, tag UNINDEXED, tokenize = 'porter');
|
||||
|
||||
-- name: MakeRecipeIndex :exec
|
||||
CREATE VIRTUAL TABLE recipes_fts USING fts5(
|
||||
@@ -67,7 +74,7 @@
|
||||
);
|
||||
|
||||
-- name: LoginName :one
|
||||
+SELECT coalesce(bio, '') AS login FROM authors WHERE id = ? LIMIT 1;
|
||||
-SELECT COALESCE(bio, '') AS login FROM authors WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: SpelledJoins :many
|
||||
SELECT a.id
|
||||
@@ -74,6 +81,6 @@
|
||||
FROM authors AS a
|
||||
+JOIN authors AS b ON a.id = b.id
|
||||
+LEFT JOIN authors AS c ON a.id = c.id
|
||||
-INNER JOIN authors AS b ON a.id = b.id
|
||||
-LEFT OUTER JOIN authors AS c ON a.id = c.id
|
||||
WHERE a.id != ? AND b.id == ? AND c.id <> ?;
|
||||
|
||||
-- name: CommaJoin :one
|
||||
Reference in New Issue
Block a user