Files
upstream-mirror 0f4df23290
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
snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 02:17:34 +05:00

74 lines
1.7 KiB
Plaintext

--- 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;