Skip to content

Commit 901a67c

Browse files
authored
Merge branch 'main' into yql-support
2 parents a44de04 + e3ad3b5 commit 901a67c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2721
-2046
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# STEP 1: Build sqlc
2-
FROM golang:1.24.2 AS builder
2+
FROM golang:1.24.5 AS builder
33

44
COPY . /workspace
55
WORKDIR /workspace

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3.8"
22
services:
33
mysql:
4-
image: "mysql/mysql-server:8.0"
4+
image: "mysql:9"
55
ports:
66
- "3306:3306"
77
restart: always

docs/howto/delete.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ CREATE TABLE authors (
55
id SERIAL PRIMARY KEY,
66
bio text NOT NULL
77
);
8+
```
9+
10+
The parameter syntax varies by database engine:
811

12+
**PostgreSQL:**
13+
```sql
914
-- name: DeleteAuthor :exec
1015
DELETE FROM authors WHERE id = $1;
1116
```
1217

18+
**MySQL and SQLite:**
19+
```sql
20+
-- name: DeleteAuthor :exec
21+
DELETE FROM authors WHERE id = ?;
22+
```
23+
1324
```go
1425
package db
1526

docs/howto/insert.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ CREATE TABLE authors (
55
id SERIAL PRIMARY KEY,
66
bio text NOT NULL
77
);
8+
```
9+
10+
The parameter syntax varies by database engine:
811

12+
**PostgreSQL:**
13+
```sql
914
-- name: CreateAuthor :exec
1015
INSERT INTO authors (bio) VALUES ($1);
1116
```
1217

18+
**MySQL and SQLite:**
19+
```sql
20+
-- name: CreateAuthor :exec
21+
INSERT INTO authors (bio) VALUES (?);
22+
```
23+
1324
```go
1425
package db
1526

@@ -51,7 +62,10 @@ CREATE TABLE authors (
5162
name text NOT NULL,
5263
bio text
5364
);
65+
```
5466

67+
**PostgreSQL:**
68+
```sql
5569
-- name: CreateAuthor :one
5670
INSERT INTO authors (
5771
name, bio
@@ -69,6 +83,27 @@ INSERT INTO authors (
6983
RETURNING id;
7084
```
7185

86+
**SQLite (with RETURNING support):**
87+
```sql
88+
-- name: CreateAuthor :one
89+
INSERT INTO authors (
90+
name, bio
91+
) VALUES (
92+
?, ?
93+
)
94+
RETURNING *;
95+
96+
-- name: CreateAuthorAndReturnId :one
97+
INSERT INTO authors (
98+
name, bio
99+
) VALUES (
100+
?, ?
101+
)
102+
RETURNING id;
103+
```
104+
105+
Note: MySQL does not support the `RETURNING` clause. Use `:execresult` instead to get the last insert ID.
106+
72107
```go
73108
package db
74109

docs/howto/select.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ CREATE TABLE authors (
88
bio text NOT NULL,
99
birth_year int NOT NULL
1010
);
11+
```
1112

13+
The parameter syntax varies by database engine:
1214

15+
**PostgreSQL:**
16+
```sql
1317
-- name: GetAuthor :one
1418
SELECT * FROM authors
1519
WHERE id = $1;
@@ -19,6 +23,17 @@ SELECT * FROM authors
1923
ORDER BY id;
2024
```
2125

26+
**MySQL and SQLite:**
27+
```sql
28+
-- name: GetAuthor :one
29+
SELECT * FROM authors
30+
WHERE id = ?;
31+
32+
-- name: ListAuthors :many
33+
SELECT * FROM authors
34+
ORDER BY id;
35+
```
36+
2237
A few new pieces of code are generated beyond the `Author` struct. An interface
2338
for the underlying database is generated. The `*sql.DB` and `*sql.Tx` types
2439
satisfy this interface.

docs/howto/update.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ CREATE TABLE authors (
1212
If your query has a single parameter, your Go method will also have a single
1313
parameter.
1414

15+
The parameter syntax varies by database engine:
16+
17+
**PostgreSQL:**
1518
```sql
1619
-- name: UpdateAuthorBios :exec
1720
UPDATE authors SET bio = $1;
1821
```
1922

23+
**MySQL and SQLite:**
24+
```sql
25+
-- name: UpdateAuthorBios :exec
26+
UPDATE authors SET bio = ?;
27+
```
28+
2029
```go
2130
package db
2231

@@ -52,12 +61,22 @@ func (q *Queries) UpdateAuthorBios(ctx context.Context, bio string) error {
5261
If your query has more than one parameter, your Go method will accept a
5362
`Params` struct.
5463

64+
**PostgreSQL:**
5565
```sql
5666
-- name: UpdateAuthor :exec
5767
UPDATE authors SET bio = $2
5868
WHERE id = $1;
5969
```
6070

71+
**MySQL and SQLite:**
72+
```sql
73+
-- name: UpdateAuthor :exec
74+
UPDATE authors SET bio = ?
75+
WHERE id = ?;
76+
```
77+
78+
Note: For MySQL and SQLite, parameters are bound in the order they appear in the query, regardless of the order in the function signature.
79+
6180
```go
6281
package db
6382

docs/reference/language-support.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ Zig `tinyzimmer/sqlc-gen-zig`_ N/A Beta B
2828
[Any] `fdietze/sqlc-gen-from-template`_ Stable Stable Stable
2929
======== ================================= =============== =============== ===============
3030

31+
Community projects
32+
******************
33+
34+
======== ================================= =============== =============== ===============
35+
Language Project MySQL PostgreSQL SQLite
36+
======== ================================= =============== =============== ===============
37+
Gleam `daniellionel01/parrot`_ Stable Stable Stable
38+
======== ================================= =============== =============== ===============
39+
3140
.. _sqlc-gen-go: https://github.com/sqlc-dev/sqlc-gen-go
3241
.. _kaashyapan/sqlc-gen-fsharp: https://github.com/kaashyapan/sqlc-gen-fsharp
3342
.. _sqlc-gen-kotlin: https://github.com/sqlc-dev/sqlc-gen-kotlin
@@ -39,7 +48,4 @@ Zig `tinyzimmer/sqlc-gen-zig`_ N/A Beta B
3948
.. _lcarilla/sqlc-plugin-php-dbal: https://github.com/lcarilla/sqlc-plugin-php-dbal
4049
.. _tandemdude/sqlc-gen-java: https://github.com/tandemdude/sqlc-gen-java
4150
.. _tinyzimmer/sqlc-gen-zig: https://github.com/tinyzimmer/sqlc-gen-zig
42-
43-
Future language support
44-
************************
45-
51+
.. _daniellionel01/parrot: https://github.com/daniellionel01/parrot

docs/requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Babel==2.17.0
22
Jinja2==3.1.6
33
MarkupSafe==3.0.2
4-
Pygments==2.19.1
4+
Pygments==2.19.2
55
Sphinx==7.4.7
6-
certifi==2025.1.31
6+
certifi==2025.8.3
77
chardet==5.2.0
88
commonmark==0.9.1
99
docutils==0.20.1
@@ -13,8 +13,8 @@ myst-parser==4.0.1
1313
packaging==25.0
1414
pyparsing==3.2.3
1515
pytz==2025.2
16-
requests==2.32.3
17-
snowballstemmer==2.2.0
16+
requests==2.32.4
17+
snowballstemmer==3.0.1
1818
sphinx-favicon==1.0.1
1919
sphinx-rtd-theme==3.0.2
2020
sphinxcontrib-applehelp==2.0.0
@@ -24,4 +24,4 @@ sphinxcontrib-jsmath==1.0.1
2424
sphinxcontrib-qthelp==2.0.0
2525
sphinxcontrib-serializinghtml==2.0.0
2626
sphinxext-rediraffe==0.2.7
27-
urllib3==2.4.0
27+
urllib3==2.5.0

go.mod

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ require (
99
github.com/cubicdaiya/gonp v1.0.4
1010
github.com/davecgh/go-spew v1.1.1
1111
github.com/fatih/structtag v1.2.0
12-
github.com/go-sql-driver/mysql v1.9.2
13-
github.com/google/cel-go v0.25.0
12+
github.com/go-sql-driver/mysql v1.9.3
13+
github.com/google/cel-go v0.26.0
1414
github.com/google/go-cmp v0.7.0
1515
github.com/jackc/pgx/v4 v4.18.3
16-
github.com/jackc/pgx/v5 v5.7.4
16+
github.com/jackc/pgx/v5 v5.7.5
1717
github.com/jinzhu/inflection v1.0.0
1818
github.com/lib/pq v1.10.9
1919
github.com/pganalyze/pg_query_go/v6 v6.1.0
2020
github.com/pingcap/tidb/pkg/parser v0.0.0-20250324122243-d51e00e5bbf0
2121
github.com/riza-io/grpc-go v0.2.0
2222
github.com/spf13/cobra v1.9.1
23-
github.com/spf13/pflag v1.0.6
23+
github.com/spf13/pflag v1.0.7
2424
github.com/tetratelabs/wazero v1.9.0
2525
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07
2626
github.com/xeipuuv/gojsonschema v1.2.0
2727
github.com/ydb-platform/ydb-go-sdk/v3 v3.108.0
2828
github.com/ydb-platform/yql-parsers v0.0.0-20250309001738-7d693911f333
29-
golang.org/x/sync v0.13.0
30-
google.golang.org/grpc v1.72.0
29+
golang.org/x/sync v0.16.0
30+
google.golang.org/grpc v1.74.2
3131
google.golang.org/protobuf v1.36.6
3232
gopkg.in/yaml.v3 v3.0.1
33-
modernc.org/sqlite v1.37.0
33+
modernc.org/sqlite v1.38.2
3434
)
3535

3636
require (
37-
cel.dev/expr v0.23.1 // indirect
37+
cel.dev/expr v0.24.0 // indirect
3838
filippo.io/edwards25519 v1.1.0 // indirect
3939
github.com/dustin/go-humanize v1.0.1 // indirect
4040
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
@@ -64,15 +64,15 @@ require (
6464
go.uber.org/atomic v1.11.0 // indirect
6565
go.uber.org/multierr v1.11.0 // indirect
6666
go.uber.org/zap v1.27.0 // indirect
67-
golang.org/x/crypto v0.36.0 // indirect
68-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
69-
golang.org/x/net v0.38.0 // indirect
70-
golang.org/x/sys v0.31.0 // indirect
71-
golang.org/x/text v0.23.0 // indirect
72-
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
73-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
67+
golang.org/x/crypto v0.38.0 // indirect
68+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
69+
golang.org/x/net v0.40.0 // indirect
70+
golang.org/x/sys v0.34.0 // indirect
71+
golang.org/x/text v0.25.0 // indirect
72+
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect
73+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
7474
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
75-
modernc.org/libc v1.62.1 // indirect
75+
modernc.org/libc v1.66.3 // indirect
7676
modernc.org/mathutil v1.7.1 // indirect
77-
modernc.org/memory v1.9.1 // indirect
77+
modernc.org/memory v1.11.0 // indirect
7878
)

0 commit comments

Comments
 (0)