Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5802484
plugin: carry the analysis core's type expression on Column
claude Sep 17, 2026
32194c9
codegen/golang: map ClickHouse, DuckDB, Spanner and SQL Server types
claude Sep 17, 2026
a075a83
codegen/golang: bind named placeholders with sql.Named, and run the n…
claude Sep 17, 2026
298b452
ci: give the ClickHouse service a password so the example can reach it
claude Sep 17, 2026
7cec97c
examples: make the examples a module of their own, and run Spanner Om…
claude Sep 18, 2026
e4783bd
docs: say N/A rather than Not implemented in the language support table
claude Sep 18, 2026
5675ff3
ci: run the examples in a job of their own
claude Sep 18, 2026
29c7517
ci: build the end-to-end module with cgo off again
claude Sep 18, 2026
6fc4352
codegen/json: leave out an unset type_expr; test-setup: install Click…
claude Sep 18, 2026
bdb4e57
codegen/golang: name the engines with constants; ci: build the end-to…
claude Sep 18, 2026
4b58b94
test-setup: keep the SQL Server it starts off the tool's own output
claude Sep 18, 2026
61ee60d
sqlc-test-setup: accept a successful mssql-conf setup without stat-in…
claude Sep 18, 2026
456a02b
codegen/json: write an unset type_expr as null again
claude Sep 18, 2026
4257811
Bind named placeholders from the compiler, scan DuckDB lists and Clic…
claude Sep 18, 2026
205daf7
plugin: pass the placeholder's name on Parameter rather than a flag
claude Sep 19, 2026
99b4108
codegen/golang: bind parameters the new engines' drivers accept, and …
claude Sep 26, 2026
abea70c
sqlc-test-setup: wait for SQL Server and Spanner Omni to serve, and k…
claude Sep 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}

# sqlc's own tests: the end-to-end suite needs PostgreSQL and MySQL, which
# sqlc-test-setup installs on the runner.
test:
runs-on: ubuntu-24.04
steps:
Expand All @@ -44,17 +47,17 @@ jobs:
env:
CGO_ENABLED: "0"

# A module of its own, so cgo stays on for the DuckDB driver the
# DuckDB golden imports.
- name: build internal/endtoend
run: go build ./...
working-directory: internal/endtoend/testdata
env:
CGO_ENABLED: "0"

- name: install databases
run: go run ./cmd/sqlc-test-setup install
run: go run ./cmd/sqlc-test-setup install postgresql mysql

- name: start databases
run: go run ./cmd/sqlc-test-setup start
run: go run ./cmd/sqlc-test-setup start postgresql mysql

- name: test ./...
run: gotestsum --junitfile junit.xml -- --tags=examples -timeout 20m -failfast ./...
Expand All @@ -66,6 +69,38 @@ jobs:
MYSQL_SERVER_URI: "root:mysecretpassword@tcp(127.0.0.1:3306)/mysql?multiStatements=true&parseTime=true"
CGO_ENABLED: "0"

# The examples run generated code against every database sqlc supports.
# They are a module of their own, so their drivers are not dependencies
# of sqlc, and cgo stays on for the DuckDB driver. sqlc-test-setup
# installs and starts every database on the runner.
examples:
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.26.5'
cache-dependency-path: |
go.sum
examples/go.sum

- name: install databases
run: go run ./cmd/sqlc-test-setup install

- name: start databases
run: go run ./cmd/sqlc-test-setup start

- name: test examples
run: go test --tags=examples -timeout 20m ./...
working-directory: examples
env:
POSTGRESQL_SERVER_URI: "postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable"
MYSQL_SERVER_URI: "root:mysecretpassword@tcp(127.0.0.1:3306)/mysql?multiStatements=true&parseTime=true"
CLICKHOUSE_SERVER_URI: "clickhouse://default:mysecretpassword@127.0.0.1:9000"
MSSQL_SERVER_URI: "sqlserver://sa:Mysecretpassword1!@127.0.0.1:1433?encrypt=disable"
SPANNER_SERVER_URI: "localhost:15000"

vuln_check:
runs-on: ubuntu-24.04
timeout-minutes: 5
Expand Down
30 changes: 23 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This document provides essential information for working with the sqlc codebase,

## Database Setup with sqlc-test-setup

The `sqlc-test-setup` tool (`cmd/sqlc-test-setup/`) automates installing and starting PostgreSQL and MySQL for tests. Both commands are idempotent and safe to re-run.
The `sqlc-test-setup` tool (`cmd/sqlc-test-setup/`) automates installing and starting PostgreSQL, MySQL, ClickHouse, SQL Server and Spanner Omni for tests. Both commands are idempotent and safe to re-run, and take the databases to act on as arguments (`postgresql`, `mysql`, `clickhouse`, `mssql`, `spanner`); with none named they act on all five.

### Install databases

Expand All @@ -24,6 +24,9 @@ This will:
- Configure the apt proxy (if `http_proxy` is set, e.g. in Claude Code remote environments)
- Install PostgreSQL via apt
- Download and install MySQL 26.7 from Oracle's deb bundle
- Download the ClickHouse 25.8 release into the user cache, where goldeneye caches it too
- Install SQL Server 2025 from Microsoft's apt repository and run its setup, accepting the EULA on your behalf (Ubuntu 22.04 and 24.04 only)
- Download the Spanner Omni standalone server release into the user cache (linux/amd64 only)
- Resolve all dependencies automatically
- Skip anything already installed

Expand All @@ -36,12 +39,20 @@ go run ./cmd/sqlc-test-setup start
This will:
- Start PostgreSQL and configure password auth (`postgres`/`postgres`)
- Start MySQL via `mysqld_safe` and set root password (`mysecretpassword`)
- Verify both connections
- Start a ClickHouse server in the background on localhost, with the default user's password `mysecretpassword`
- Start SQL Server through systemd, or in the background where there is no systemd, with the sa password `Mysecretpassword1!`
- Start a Spanner Omni single server in the background, serving plaintext gRPC on port 15000
- Verify the connections
- Skip steps that are already done (running services, existing config)

Connection URIs after start:
- PostgreSQL: `postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable`
- MySQL: `root:mysecretpassword@tcp(127.0.0.1:3306)/mysql`
- ClickHouse: `clickhouse://default:mysecretpassword@127.0.0.1:9000` (`CLICKHOUSE_SERVER_URI`)
- SQL Server: `sqlserver://sa:Mysecretpassword1!@127.0.0.1:1433?encrypt=disable` (`MSSQL_SERVER_URI`)
- Spanner Omni: `localhost:15000` (`SPANNER_SERVER_URI`)

The examples' tests for ClickHouse, SQL Server and Spanner read those variables and skip when unset. `docker-compose.yml` runs the same databases for anyone who prefers containers.

### Run tests

Expand Down Expand Up @@ -172,9 +183,13 @@ them as an artifact.

### Example Tests

- **Location:** `/examples/` directory
- **Requirements:** Tagged with "examples", requires live databases
- **Databases:** PostgreSQL, MySQL, SQLite examples
- **Location:** `/examples/` directory, a Go module of its own so the
drivers the examples run against are not dependencies of sqlc, and so
cgo stays on for the DuckDB driver
- **Requirements:** Tagged with "examples", requires live databases; run
with `cd examples && go test --tags=examples ./...`
- **Databases:** PostgreSQL, MySQL, SQLite, ClickHouse, DuckDB, Spanner and
SQL Server examples; each skips when its server is not named

## Database Services

Expand Down Expand Up @@ -207,8 +222,9 @@ make start # Start database containers

- **File:** `.github/workflows/ci.yml`
- **Go Version:** 1.26.4
- **Database Setup:** Uses `sqlc-test-setup` (not Docker) to install and start PostgreSQL and MySQL directly on the runner
- **Test Command:** `gotestsum --junitfile junit.xml -- --tags=examples -timeout 20m ./...`
- **Jobs:** `build` cross-compiles sqlc with cgo off; `test` runs sqlc's own tests; `examples` runs the examples module against every database; `vuln_check` runs `govulncheck`
- **Database Setup:** `sqlc-test-setup` (not Docker) installs and starts the databases directly on the runner: PostgreSQL and MySQL for `test`, and all five for `examples`
- **Test Command:** `gotestsum --junitfile junit.xml -- --tags=examples -timeout 20m ./...` in `test`, and `go test --tags=examples ./...` under `examples/` in `examples`
- **Additional Checks:** `govulncheck` for vulnerability scanning

## Development Workflow
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ test-managed:

vet:
go vet ./...
cd ./examples && go vet --tags=examples ./...

test-examples:
go test --tags=examples ./...
cd ./examples && go test --tags=examples ./...

build-endtoend:
cd ./internal/endtoend/testdata && go build ./...
Expand Down
Loading
Loading