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/mysql/exec.json
vendored
Normal file
5
internal/endtoend/testdata/fmt/mysql/exec.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"command": "fmt",
|
||||
"args": ["--diff"],
|
||||
"contexts": ["base"]
|
||||
}
|
||||
72
internal/endtoend/testdata/fmt/mysql/query.sql
vendored
Normal file
72
internal/endtoend/testdata/fmt/mysql/query.sql
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
-- name: GetAuthor :one
|
||||
select id,name , bio from authors
|
||||
where id = ? limit 1;
|
||||
|
||||
# hash comment
|
||||
-- name: ListAuthors :many
|
||||
SELECT id, name, bio FROM authors
|
||||
ORDER BY name DESC;
|
||||
|
||||
-- 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: CountSigils :one
|
||||
SELECT count(*) FROM authors
|
||||
WHERE id <> ? AND name <> @user_name; # session variable stays
|
||||
|
||||
-- name: CastUnsigned :one
|
||||
SELECT CAST(id AS UNSIGNED) FROM authors LIMIT 1;
|
||||
|
||||
-- name: FirstTwin :one
|
||||
SELECT id FROM authors LIMIT 1;
|
||||
|
||||
-- name: SecondTwin :one
|
||||
SELECT id FROM authors LIMIT 1;
|
||||
|
||||
-- name: CreateAuthor :execresult
|
||||
insert into authors (
|
||||
name, bio
|
||||
) values (
|
||||
?, ?
|
||||
);
|
||||
|
||||
-- name: CasePreserved :many
|
||||
SELECT ID, Name FROM Authors WHERE Name <> '' ORDER BY Name;
|
||||
|
||||
-- name: LiteralsSurvive :one
|
||||
SELECT true AS t, false AS f, 1.50 AS score, CASE WHEN name = '' THEN NULL ELSE name END AS n FROM authors LIMIT 1;
|
||||
|
||||
-- name: DistinctNames :many
|
||||
SELECT DISTINCT name FROM authors;
|
||||
|
||||
-- name: UnionOrdered :many
|
||||
SELECT name AS foo FROM authors
|
||||
UNION
|
||||
SELECT bio AS foo FROM authors
|
||||
ORDER BY foo;
|
||||
|
||||
-- name: ConcatNames :many
|
||||
SELECT group_concat(DISTINCT name ORDER BY name DESC SEPARATOR ' ') FROM authors GROUP BY bio;
|
||||
|
||||
-- name: Hinted :one
|
||||
SELECT /*+ MAX_EXECUTION_TIME(1000) */ id FROM authors LIMIT 1;
|
||||
|
||||
-- name: UpdateWithJoin :exec
|
||||
UPDATE authors AS a JOIN authors AS p ON p.id = a.id
|
||||
SET a.name = ?
|
||||
WHERE p.bio IS NOT NULL;
|
||||
|
||||
-- name: ShowWarnings :many
|
||||
SHOW WARNINGS;
|
||||
|
||||
CREATE TABLE scores (points decimal(10, 5), views bigint unsigned NOT NULL);
|
||||
5
internal/endtoend/testdata/fmt/mysql/schema.sql
vendored
Normal file
5
internal/endtoend/testdata/fmt/mysql/schema.sql
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE authors (
|
||||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
bio text
|
||||
);
|
||||
9
internal/endtoend/testdata/fmt/mysql/sqlc.yaml
vendored
Normal file
9
internal/endtoend/testdata/fmt/mysql/sqlc.yaml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "mysql"
|
||||
schema: "schema.sql"
|
||||
queries: "query.sql"
|
||||
gen:
|
||||
go:
|
||||
package: "querytest"
|
||||
out: "go"
|
||||
73
internal/endtoend/testdata/fmt/mysql/stdout.txt
vendored
Normal file
73
internal/endtoend/testdata/fmt/mysql/stdout.txt
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
--- a/query.sql
|
||||
+++ b/query.sql
|
||||
@@ -1,6 +1,8 @@
|
||||
-- name: GetAuthor :one
|
||||
+SELECT id, name, bio
|
||||
+FROM authors
|
||||
+WHERE id = ?
|
||||
+LIMIT 1;
|
||||
-select id,name , bio from authors
|
||||
-where id = ? limit 1;
|
||||
|
||||
# hash comment
|
||||
-- name: ListAuthors :many
|
||||
@@ -7,4 +9,5 @@
|
||||
+SELECT id, name, bio
|
||||
+FROM authors
|
||||
-SELECT id, name, bio FROM authors
|
||||
ORDER BY name DESC;
|
||||
|
||||
-- name: PickyQuery :many
|
||||
@@ -11,7 +14,8 @@
|
||||
+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
|
||||
@@ -21,8 +25,9 @@
|
||||
SELECT /* inline note */ id, name FROM authors ORDER BY name;
|
||||
|
||||
-- name: CountSigils :one
|
||||
+SELECT count(*)
|
||||
+FROM authors
|
||||
+WHERE id != ? AND name != @user_name; # session variable stays
|
||||
-SELECT count(*) FROM authors
|
||||
-WHERE id <> ? AND name <> @user_name; # session variable stays
|
||||
|
||||
-- name: CastUnsigned :one
|
||||
SELECT CAST(id AS UNSIGNED) FROM authors LIMIT 1;
|
||||
@@ -34,14 +39,11 @@
|
||||
SELECT id FROM authors LIMIT 1;
|
||||
|
||||
-- name: CreateAuthor :execresult
|
||||
+INSERT INTO authors (name, bio)
|
||||
+VALUES (?, ?);
|
||||
-insert into authors (
|
||||
- name, bio
|
||||
-) values (
|
||||
- ?, ?
|
||||
-);
|
||||
|
||||
-- name: CasePreserved :many
|
||||
+SELECT ID, Name FROM Authors WHERE Name != '' ORDER BY Name;
|
||||
-SELECT ID, Name FROM Authors WHERE Name <> '' ORDER BY Name;
|
||||
|
||||
-- name: LiteralsSurvive :one
|
||||
SELECT true AS t, false AS f, 1.50 AS score, CASE WHEN name = '' THEN NULL ELSE name END AS n FROM authors LIMIT 1;
|
||||
@@ -62,7 +64,8 @@
|
||||
SELECT /*+ MAX_EXECUTION_TIME(1000) */ id FROM authors LIMIT 1;
|
||||
|
||||
-- name: UpdateWithJoin :exec
|
||||
+UPDATE authors AS a
|
||||
+JOIN authors AS p ON p.id = a.id
|
||||
-UPDATE authors AS a JOIN authors AS p ON p.id = a.id
|
||||
SET a.name = ?
|
||||
WHERE p.bio IS NOT NULL;
|
||||
|
||||
Reference in New Issue
Block a user