Releases: sqlc-dev/sqlc
v1.27.0
Release notes
Sunsetting hosted ephemeral databases
On September 4th, 2024, we'll be turning off support for hosted ephemeral databases in sqlc Cloud. If you use managed databases or query verification with sqlc Cloud, you'll need to update to 1.27.0 to avoid any issues. I've already emailed you if you're using this feature. It's more than likely that you are not!
Bug Fixes
- (dbmanager) Add leading slash to db uri path rewrite (#3493)
- (verify) Include database engine in request (#3522)
Features
- (golang) Add initialisms configuration (#3308)
- (compiler) Support subqueries in the FROM clause (second coming) (#3310)
- Managed databases with any accessible server (#3421)
- (vet) Use new dbmanager client (#3423)
- (verify) Update verify to work with managed databases (#3425)
Documentation
- Fix typo in config (#3358)
- Resolve a typo in configuration keys (#3349)
- Add sponsorship information to README (#3413)
- Update the language-support to include C# (#3408)
- Add migration guide for hosted managed databases (#3417)
- Fix readme links (#3424)
- Update the managed db and verify documentation (#3426)
- Add sponsor image (#3428)
- Add Ruby as supported language (#3487)
- Update migrating-to-sqlc-gen-kotlin.md (#3454)
- Fix typo in comment (#3316)
- Fix deprecated build tag format (#3361)
Testing
v1.26.0
Release notes
This release is mainly a bug fix release. It also includes an important security fix for users using output plugins.
Changes
Bug Fixes
- (docker) Use distroless base image instead of scratch (#3111)
- (generate) Ensure files are created inside output directory (#3195)
- (mysql) BREAKING: Use
int16
for MySQLSMALLINT
andYEAR
(#3106) - (mysql) BREAKING: Use
int8
for MySQL TINYINT (#3298) - (mysql) Variables not resolving in ORDER BY statements (#3115)
- (opts) Validate SQL package and driver options (#3241)
- (postgres/batch) Ignore query_parameter_limit for batches
- (scripts) Remove deprecated test output regeneration script (#3105)
- (sqlite) Correctly skip unknown statements (#3239)
Documentation
Features
- (generate) Avoid generating empty Go imports (#3135)
- (mysql) Add NEXTVAL() to the MySQL catalog (#3147)
- (mysql) Support json.RawMessage for LOAD DATA INFILE (#3099)
Build
v1.25.0
What's new
Add tags to push and verify
You can add tags when pushing schema and queries to sqlc Cloud. Tags operate like git tags, meaning you can overwrite previously-pushed tag values. We suggest tagging pushes to associate them with something relevant from your environment, e.g. a git tag or branch name.
$ sqlc push --tag v1.0.0
Once you've created a tag, you can refer to it when verifying changes, allowing you
to compare the existing schema against a known set of previous queries.
$ sqlc verify --against v1.0.0
C-ya, cgo
Over the last month, we've switched out a few different modules to remove our reliance on cgo. Previously, we needed cgo for three separate functions:
- Parsing PostgreSQL queries with pganalyze/pg_query_go
- Running SQLite databases with mattn/go-sqlite3
- Executing WASM / WASI code with bytecodealliance/wasmtime-go
With the help of the community, we found cgo-free alternatives for each module:
- Parsing PostgreSQL queries, now using wasilibs/go-pgquery
- Running SQLite databases, now using modernc.org/sqlite
- Executing WASM / WASI code, now using tetratelabs/wazero
For the first time, Windows users can enjoy full PostgreSQL support without using WSL. It's a Christmas miracle!
If you run into any issues with the updated dependencies, please open an issue.
Bug Fixes
- (codegen) Wrong yaml annotation in go codegen options for output_querier_file_name (#3006)
- (codegen) Use derived ArrayDims instead of deprecated attndims (#3032)
- (codegen) Take the maximum array dimensions (#3034)
- (compiler) Skip analysis of queries without a
name
annotation (#3072) - (codegen/golang) Don't import
"strings"
forsqlc.slice()
with pgx (#3073)
Documentation
- Add name to query set configuration (#3011)
- Add a sidebar link for
push
, add Go plugin link (#3023) - Update banner for sqlc-gen-typescript (#3036)
- Add strict_order_by in doc (#3044)
- Re-order the migration tools list (#3064)
Features
- (analyzer) Return zero values when encountering unexpected ast nodes (#3069)
- (codegen/go) add omit_sqlc_version to Go code generation (#3019)
- (codgen/go) Add
emit_sql_as_comment
option to Go code plugin (#2735) - (plugins) Use wazero instead of wasmtime (#3042)
- (push) Add tag support (#3074)
- (sqlite) Support emit_pointers_for_null_types (#3026)
Testing
- (endtoend) Enable for more build targets (#3041)
- (endtoend) Run MySQL and PostgreSQL locally on the runner (#3095)
- (typescript) Test against sqlc-gen-typescript (#3046)
- Add tests for omit_sqlc_version (#3020)
- Split schema and query for test (#3094)
Build
- (deps) Bump idna from 3.4 to 3.6 in /docs (#3010)
- (deps) Bump sphinx-rtd-theme from 1.3.0 to 2.0.0 in /docs (#3016)
- (deps) Bump golang from 1.21.4 to 1.21.5 (#3043)
- (deps) Bump actions/setup-go from 4 to 5 (#3047)
- (deps) Bump github.com/jackc/pgx/v5 from 5.5.0 to 5.5.1 (#3050)
- (deps) Upgrade to latest version of github.com/wasilibs/go-pgquery (#3052)
- (deps) Bump google.golang.org/grpc from 1.59.0 to 1.60.0 (#3053)
- (deps) Bump babel from 2.13.1 to 2.14.0 in /docs (#3055)
- (deps) Bump actions/upload-artifact from 3 to 4 (#3061)
- (deps) Bump modernc.org/sqlite from 1.27.0 to 1.28.0 (#3062)
- (deps) Bump golang.org/x/crypto from 0.14.0 to 0.17.0 (#3068)
- (deps) Bump google.golang.org/grpc from 1.60.0 to 1.60.1 (#3070)
- (deps) Bump google.golang.org/protobuf from 1.31.0 to 1.32.0 (#3079)
- (deps) Bump github.com/tetratelabs/wazero from 1.5.0 to 1.6.0 (#3096)
- (sqlite) Update to antlr 4.13.1 (#3086)
- (sqlite) Disable modernc for WASM (#3048)
- (sqlite) Switch from mattn/go-sqlite3 to modernc.org/sqlite (#3040)
New Contributors
- @pgLydia made their first contribution in #3006
- @bertold made their first contribution in #3019
- @hendrikhofstadt made their first contribution in #3032
- @CNLHC made their first contribution in #3044
- @KevinSnyderCodes made their first contribution in #3051
- @k-omotani made their first contribution in #3056
- @mohammed90 made their first contribution in #3064
- @jasoncabot made their first contribution in #2735
- @benhoyt made their first contribution in #3026
Full Changelog: v1.24.0...v1.25.0
v1.24.0
What's new
Verifying database schema changes
Schema updates and poorly-written queries often bring down production databases. That’s bad.
Out of the box, sqlc generate
catches some of these issues. Running sqlc vet
with the sqlc/db-prepare
rule catches more subtle problems. But there is a large class of issues that sqlc can’t prevent by looking at current schema and queries alone.
For instance, when a schema change is proposed, existing queries and code running in production might fail when the schema change is applied. Enter sqlc verify
, which analyzes existing queries against new schema changes and errors if there are any issues.
Let's look at an example. Assume you have these two tables in production.
CREATE TABLE users (
id UUID PRIMARY KEY
);
CREATE TABLE user_actions (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
action TEXT,
created_at TIMESTAMP
);
Your application contains the following query to join user actions against the users table.
-- name: GetUserActions :many
SELECT * FROM users u
JOIN user_actions ua ON u.id = ua.user_id
ORDER BY created_at;
So far, so good. Then assume you propose this schema change:
ALTER TABLE users ADD COLUMN created_at TIMESTAMP;
Running sqlc generate
fails with this change, returning a column reference "created_at" is ambiguous
error. You update your query to fix the issue.
-- name: GetUserActions :many
SELECT * FROM users u
JOIN user_actions ua ON u.id = ua.user_id
ORDER BY u.created_at;
While that change fixes the issue, there's a production outage waiting to happen. When the schema change is applied, the existing GetUserActions
query will begin to fail. The correct way to fix this is to deploy the updated query before applying the schema migration.
It ensures migrations are safe to deploy by sending your current schema and queries to sqlc cloud. There, we run the queries for your latest push against your new schema changes. This check catches backwards incompatible schema changes for existing queries.
Here sqlc verify
alerts you to the fact that ORDER BY "created_at" is ambiguous.
$ sqlc verify
FAIL: app query.sql
=== Failed
=== FAIL: app query.sql GetUserActions
ERROR: column reference "created_at" is ambiguous (SQLSTATE 42702)
By the way, this scenario isn't made up! It happened to us a few weeks ago. We've been happily testing early versions of verify
for the last two weeks and haven't had any issues since.
This type of verification is only the start. If your application is deployed on-prem by your customers, verify
could tell you if it's safe for your customers to rollback to an older version of your app, even after schema migrations have been run.
Rename upload
command to push
We've renamed the upload
sub-command to push
. We changed the data sent along in a push request. Upload used to include the configuration file, migrations, queries, and all generated code. Push drops the generated code in favor of including the plugin.GenerateRequest, which is the protocol buffer message we pass to codegen plugins.
We also add annotations to each push. By default, we include these environment variables if they are present:
GITHUB_REPOSITORY
GITHUB_REF
GITHUB_REF_NAME
GITHUB_REF_TYPE
GITHUB_SHA
Like upload, push
should be run when you tag a release of your application. We run it on every push to main, as we continuously deploy those commits.
MySQL support in createdb
The createdb
command, added in the last release, now supports MySQL. If you have a cloud project configured, you can use sqlc createdb
to spin up a new ephemeral database with your schema and print its connection string to standard output. This is useful for integrating with other tools. Read more in the managed databases documentation.
Plugin interface refactor
This release includes a refactored plugin interface to better support future functionality. Plugins now support different methods via a gRPC service interface, allowing plugins to support different functionality in a backwards-compatible way.
By using gRPC interfaces, we can even (theoretically) support remote plugins, but that's something for another day.
New Contributors
- @xeraph-dev made their first contribution in #2924
- @bilalmirza74 made their first contribution in #2931
- @hawkingrei made their first contribution in #2943
- @iamwavecut made their first contribution in #2955
- @eduardolat made their first contribution in #2995
Full Changelog: v1.23.0...v1.24.0
v1.23.0
What's new
Database-backed query analysis
With a database connection configured, sqlc generate
will gather metadata from that database to support its query analysis. Turning this on resolves a large number of issues in the backlog related to type inference and more complex queries. The easiest way to try it out is with managed databases.
The database-backed analyzer currently supports PostgreSQL, with MySQL and SQLite support planned in the future.
New createdb
command
When you have a cloud project configured, you can use the new sqlc createdb
command to spin up a new ephemeral database with your schema and print its connection string to standard output. This is useful for integrating with other tools. Read more in the managed databases documentation.
Support for pgvector
If you're using pgvector, say goodbye to custom overrides! sqlc now generates code using pgvector-go as long as you're using pgx
. The pgvector extension is also available in managed databases.
Go build tags
With the new emit_build_tags
configuration parameter you can set build tags for sqlc to add at the top of generated source files.
What's Changed
- chore(endtoend): Fix test output for do tests by @kyleconroy in #2782
- docs: Add stable anchors to changelog by @kyleconroy in #2784
- build(deps): bump packaging from 23.1 to 23.2 in /docs by @dependabot in #2791
- Update changelog.md by @kyleconroy in #2796
- docs: Add sqlc upload to CI / CD guide by @kyleconroy in #2797
- build(deps): bump urllib3 from 2.0.5 to 2.0.6 in /docs by @dependabot in #2798
- build(deps): bump babel from 2.12.1 to 2.13.0 in /docs by @dependabot in #2799
- test(endtoend): Split shema and queries by @kyleconroy in #2803
- test: Fix a few incorrect testcases by @kyleconroy in #2804
- build(deps): bump golang.org/x/sync from 0.3.0 to 0.4.0 by @dependabot in #2810
- build(deps): bump golang from 1.21.1 to 1.21.2 by @dependabot in #2811
- feat(codegen): add support for build tags (#2012) by @Hyuga-Tsukui in #2807
- docs: fix broken link, add clarity to plugins doc by @andrewmbenton in #2813
- feat(generate): reorder codegen handlers to prefer plugins by @andrewmbenton in #2814
- docs: add clarity and reference to JSON tags by @kalogs-c in #2819
- build(deps): bump github.com/google/go-cmp from 0.5.9 to 0.6.0 by @dependabot in #2826
- build(deps): bump golang from 1.21.2 to 1.21.3 by @dependabot in #2824
- build(deps): bump google.golang.org/grpc from 1.58.2 to 1.58.3 by @dependabot in #2825
- ci: bump go version in workflows by @andrewmbenton in #2835
- refactor(codegen): remove golang and json settings from plugin proto by @andrewmbenton in #2822
- feat(devenv): add vscode settings.json with auto newline by @andrewmbenton in #2834
- feat(generate): support yml extension by @xsadia in #2828
- build(deps): bump golang.org/x/net from 0.12.0 to 0.17.0 by @dependabot in #2836
- feat(analyzer): Analyze queries using a running PostgreSQL database by @kyleconroy in #2805
- fix(codegen): Correct column names in :copyfrom by @kyleconroy in #2838
- feat(sql/ast): Render AST to SQL by @kyleconroy in #2815
- docs: Replace form with dashboard link by @kyleconroy in #2840
- fix(compiler): Search SELECT and UPDATE the same way by @kyleconroy in #2841
- fix(dolphin): Support more UNIONs for MySQL by @kyleconroy in #2843
- fix(compiler): Account for parameters without parents by @kyleconroy in #2844
- fix(postgresql): Remove temporary pool config by @kyleconroy in #2851
- fix(golang): Escape reserved keywords by @kyleconroy in #2849
- fix(mysql): Handle simplified CASE statements by @kyleconroy in #2852
- feat(codegen): Include plugin information by @kyleconroy in #2846
- fix(engine/dolphin): support enum in ALTER definition by @sapk in #2680
- fix(mysql): Add, drop, rename and change enum values by @kyleconroy in #2853
- feat(postgresql): Add ALTER VIEW ... SET SCHEMA by @kyleconroy in #2855
- fix(config): Validate
database
config in all cases by @andrewmbenton in #2856 - test: Add more database analyzer test cases by @kyleconroy in #2854
- feat(compiler): Parse query parameter metadata from comments by @andrewmbenton in #2850
- fix(compiler): Use correct func signature for
CommentSyntax
on windows by @andrewmbenton in #2867 - fix(codegen/go): Prevent filtering of embedded struct fields by @andrewmbenton in #2868
- fix(compiler): Support functions with OUT params by @kyleconroy in #2865
- docs: Update examples to use pgx/v5 by @andrewmbenton in #2863
- test: Add more analyzer test cases by @andrewmbenton in #2866
- build(deps): bump urllib3 from 2.0.6 to 2.0.7 in /docs by @dependabot in #2872
- patch: use docker compose v2 and update MYSQL_DATABASE env var by @juanjuanzero in #2870
- build(deps): bump google.golang.org/grpc from 1.58.3 to 1.59.0 by @dependabot in #2876
- feat(postgresql): Support system columns on tables by @kyleconroy in #2871
- feat(compiler): Support LEFT JOIN on aliased table by @kyleconroy in #2873
- fix(compiler): Pull in array information from analyzer by @kyleconroy in #2864
- test: Add more test cases for new analyzer by @kyleconroy in #2879
- feat: Improve messaging for common cloud config and rpc errors by @andrewmbenton in #2885
- fix(analyzer): Error on unexpanded star expression by @kyleconroy in #2882
- test(endtoend): Enabled managed-db tests in CI by @kyleconroy in #2883
- feat: Abort compiler when rpc fails as unauthenticated by @andrewmbenton in #2887
- feat(codegen): Add support for pgvector and pgvector-go by @kyleconroy in #2888
- docs: Update getting started guides, use pgx for Postgres guide by @andrewmbenton in #2891
- docs: Use managed databases in PostgreSQL getting started guide by @andrewmbenton in #2892
- test: Enabled pgvector tests for managed dbs by @kyleconroy in #2893
- feat(analyzer): Cache query analysis by @kyleconroy in #2889
- fix(vet): Remove rollback statements from DDL by @kyleconroy in #2895
- feat(createdb): Create ephemeral databases by @kyleconroy in #2894
- docs: Update managed databases doc to discuss codegen by @andrewmbenton in #2897
- docs: Add managed dbs to CI/CD and vet guides by @kyleconroy in #2896
- feat(debug): Add databases=managed debug option by @kyleconroy in #2898
- build(deps): Upgrade wasmtime-go from 13.0.0 to 14.0.0 by @kyleconroy in #2900
- feat(config): Remove managed database validation by @kyleconroy in #2901
- refactor(codegen): Removed deprecated code and improved speed by @quenbyako in #2899
- docs: Document database-backed query analyzer by @kyleconroy in #2904
- docs: Release notes for v1.23.0 by @andrewmbenton in #2907
- Release v1.23.0 by @kyleconroy in #2908
New Contributors
- @Hyuga-Tsukui made their first contri...
v1.22.0
What's new
Managed databases for sqlc vet
If you're using sqlc vet to write rules that require access to a running database, sqlc
can now start and manage that database for you. PostgreSQL support is available today, with MySQL on the way.
When you turn on managed databases, sqlc
will use your schema to create a template database that it can copy to make future runs of sqlc vet
very performant.
This feature relies on configuration obtained via sqlc Cloud. If you're interested in early access you can sign up here or send us an email at hello@sqlc.dev.
Read more in the managed databases documentation.
What's changed
- build(deps): bump golang from 1.21.0 to 1.21.1 by @dependabot in #2711
- fix(codegen/golang): Refactor imports code to match templates by @kyleconroy in #2709
- ci: bump go version to latest in workflows by @andrewmbenton in #2722
- fix(codegen/golang): support name type by @orisano in #2715
- fix(wasm): Move Runner struct to shared file by @kyleconroy in #2725
- fix(engine/sqlite): fix grammer to avoid missing join_constraint by @orisano in #2732
- fix(convert): Support YAML anchors in plugin options by @kyleconroy in #2733
- Enables the configuration of copyfrom.go similar to quierer and friends by @XanderAtGoingDutch in #2727
- test(endtoend): Verify all schemas in endtoend by @kyleconroy in #2744
- test(examples): Use a hosted database for example testing by @kyleconroy in #2749
- test(endtoend): Pull region from environment by @kyleconroy in #2750
- build(deps): bump google.golang.org/grpc from 1.57.0 to 1.58.1 by @dependabot in #2743
- build(deps): Bump wasmtime-go from v12 to v13 by @kyleconroy in #2756
- docs: clarify nullable override behavior by @andrewmbenton in #2753
- build(windows): Downgrade to mingw 11.2.0 by @kyleconroy in #2757
- build(deps): bump urllib3 from 2.0.4 to 2.0.5 in /docs by @dependabot in #2747
- build(deps): bump google.golang.org/grpc from 1.58.1 to 1.58.2 by @dependabot in #2758
- feat(vet): Run rules against a managed database by @kyleconroy in #2751
- chore(endtoend): Skip tests if secrets are missing by @kyleconroy in #2763
- docs: Add managed databases to sidebar by @kyleconroy in #2764
- fix: Disallow time.Time in mysql :copyfrom queries, not all queries by @Jille in #2768
- chore: Skip certain tests on PRs by @kyleconroy in #2769
- feat(upload): Point upload command at new endpoint by @kyleconroy in #2772
- fix(engine/sqlite): Fix convert process for VALUES by @orisano in #2737
- docs: Release notes for v1.22.0 by @andrewmbenton in #2773
- docs: Pull renaming and type overrides into separate sections by @kyleconroy in #2774
- docs: Update the docs banner for managed dbs by @kyleconroy in #2775
- build(deps): bump github.com/google/cel-go from 0.18.0 to 0.18.1 by @dependabot in #2778
- feat(compiler): Support DO statements by @kyleconroy in #2777
- docs: update changelog with all v1.22.0 changes by @andrewmbenton in #2780
- cmd/sqlc: Bump version to v1.22.0 by @kyleconroy in #2776
New Contributors
- @XanderAtGoingDutch made their first contribution in #2727
Full Changelog: v1.21.0...v1.22.0
v1.21.0
What's new
MySQL engine improvements
sqlc
previously didn't know how to parse a CALL
statement when using the MySQL engine,
which meant it was impossible to use sqlc with stored procedures in MySQL databases.
Additionally, sqlc
now supports IS [NOT] NULL
in queries. And LIMIT
and OFFSET
clauses
now work with UNION
.
SQLite engine improvements
GitHub user @orisano continues to bring bugfixes and
improvements to sqlc
's SQLite engine. See the "Changes" section below for the
full list.
Plugin access to environment variables
If you're authoring a sqlc plugin, you can now configure
sqlc to pass your plugin the values of specific environment variables.
For example, if your plugin
needs the PATH
environment variable, add PATH
to the env
list in the
plugins
collection.
version: '2'
sql:
- schema: schema.sql
queries: query.sql
engine: postgresql
codegen:
- out: gen
plugin: test
plugins:
- name: test
env:
- PATH
wasm:
url: https://github.com/sqlc-dev/sqlc-gen-test/releases/download/v0.1.0/sqlc-gen-test.wasm
sha256: 138220eae508d4b65a5a8cea555edd155eb2290daf576b7a8b96949acfeb3790
A variable named SQLC_VERSION
is always included in the plugin's
environment, set to the version of the sqlc
executable invoking it.
What's Changed
- feat(endtoend/testdata): added two sqlite
CAST
tests and rearranged postgres tests for same by @andrewmbenton in #2551 - build(deps): Bump wasmtime from v8.0.0 to v11.0.0 by @kyleconroy in #2553
- feat(docs): add a reference to type overriding in datatypes.md by @andrewmbenton in #2557
- docs: Update Docker installation instructions by @kyleconroy in #2552
- docs: Modify config file version of mysql tutorial by @ken2403 in #2555
- myriad formatting changes by @verygoodsoftwarenotvirus in #2558
- build(deps): bump golang from 1.20.6 to 1.20.7 by @dependabot in #2563
- build(deps): bump chardet from 5.1.0 to 5.2.0 in /docs by @dependabot in #2562
- fix(engine/sqlite): support quoted identifier by @orisano in #2556
- feat(engine/sqlite): support COLLATE for sqlite WHERE clause by @orisano in #2554
- fix(engine/sqlite): fix compile error by @orisano in #2564
- fix(engine/sqlite): fixed detection of column alias without AS by @orisano in #2560
- fix(ci): bump go version for govulncheck in ci.yml by @andrewmbenton in #2568
- fix: remove references to deprecated
--experimental
flag by @andrewmbenton in #2567 - fix(postgres): Fixed a problem with array dimensions disappearing when using "ALTER TABLE ADD COLUMN" by @orisano in #2572
- fix: remove GitHub sponsor integration by @andrewmbenton in #2574
- fix(docs): improve discussion of prepared statements support by @andrewmbenton in #2604
- build(deps): bump github.com/pganalyze/pg_query_go/v4 from 4.2.1 to 4.2.3 by @dependabot in #2583
- docs: Reword phrase about pgx and multidimensional arrays by @rollulus in #2619
- Gitignore Vim swap files by @Jille in #2616
- build(deps): bump golang from 1.20.7 to 1.21.0 by @dependabot in #2596
- build(deps): bump github.com/jackc/pgx/v5 from 5.4.2 to 5.4.3 by @dependabot in #2582
- build(deps): bump pygments from 2.15.1 to 2.16.1 in /docs by @dependabot in #2584
- build(deps): bump sphinxcontrib-applehelp from 1.0.4 to 1.0.7 in /docs by @dependabot in #2620
- build(deps): bump sphinxcontrib-qthelp from 1.0.3 to 1.0.6 in /docs by @dependabot in #2622
- build(deps): bump github.com/google/cel-go from 0.17.1 to 0.17.6 by @dependabot in #2650
- fix Go struct tag parsing by @josharian in #2606
- build(deps): bump sphinxcontrib-serializinghtml from 1.1.5 to 1.1.9 in /docs by @dependabot in #2641
- build: Upgrade from Go 1.20 to Go 1.21 by @kyleconroy in #2665
- refactor(astutils): remove redundant nil check in
Walk
by @Juneezee in #2660 - build(deps): bump sphinxcontrib-devhelp from 1.0.2 to 1.0.5 in /docs by @dependabot in #2621
- build(deps): Bump github.com/bytecodealliance/wasmtime-go from v11.0.0 to v12.0.0 by @kyleconroy in #2666
- fix(compiler): Fix to not scan children under ast.RangeSubselect when retrieving table listing by @orisano in #2573
- feat(mysql): Add parser support for IS [NOT] NULL by @Jille in #2651
- fix(engine/sqlite): support NOT IN by @orisano in #2587
- fix(codegen/golang): Fixed detection of the used package by @orisano in #2597
- fix(engine/dolphin): Fixed problem that LIMIT OFFSET cannot be used with
UNION ALL
by @orisano in #2613 - fix(compiler): support identifiers with schema by @orisano in #2579
- fix(compiler): Fix column expansion to work with quoted non-keyword identifiers by @orisano in #2576
- feat(engine/dolphin): support CALL statement by @orisano in #2614
- fix(codegen): Compare define type in codegen by @tychy in #2578
- build(deps): bump sphinx-rtd-theme from 1.2.2 to 1.3.0 in /docs by @dependabot in #2670
- build(deps): bump sphinxcontrib-htmlhelp from 2.0.1 to 2.0.4 in /docs by @dependabot in #2671
- feat(codegen): Allow plugins to access environment variables by @kyleconroy in #2669
- fix(engine/sqlite): Fix ast when using compound operator by @orisano in #2673
- fix(engine/sqlite): Fix to handle join clauses correctly by @orisano in #2674
- fix(codegen): use correct Go types for bit strings and cid/oid/tid/xid with pgx/v4 by @andrewmbenton in #2668
- build(deps): bump github.com/google/cel-go from 0.17.6 to 0.18.0 by @dependabot in #2691
- docs: Missing emit_pointers_for_null_types configuration option in version 2 (#2682) by @topazur in #2683
- fix(endtoend): Ensure all SQL works against PostgreSQL by @kyleconroy in #2684
- build(deps): bump actions/checkout from 3 to 4 by @dependabot in #2694
- build(deps): bump pytz from 2023.3 to 2023.3.post1 in /docs by @dependabot in #2695
- chore: fix typo by @remyleone in #2696
- chore: fix typo by @remyleone in #2697
- docs: Document sqlc.* macros by @kyleconroy in #2698
- docs(mysql): Document parseTime=true requirement by @kyleconroy in #2699
- docs: add atlas to the list of supported migration frameworks by @andrewmbenton in #2700
- docs: minor updates to insert howto by @andrewmbenton in #2701
- build(devenv): bump go from 1.20.7 to 1.21.0 by @kyleconroy in #2702
- feat(config): Add JSON schema files for configs by @kyleconroy in #2703
- feat(cmd/sqlc): Bump version to 1.21.0 by @andrewmbenton in #2704
- cmd/sqlc: Bump version to v1.21.0 by @kyleconroy in #2705
New Contributors
- @ken2403 made their first contribution in #2555
- @verygoodsoftwarenotvirus made their first contribution in #2558
- @rollulus made their first contribution in #2619
- @tychy made their first contribution in #2578
- @topazur made their first contribution in #2683
- @remyleone made their first contribution in #2696
Full Changelog: v1.20.0...v1.21.0
v1.20.0
What's Changed
- Mention UUID type for pgx/v5 by @peterwillis in #2448
- Update BUG_REPORT.yml by @andrewmbenton in #2460
- scripts: Add new version to BUG_REPORT.yml by @kyleconroy in #2461
- build: Run all supported versions of MySQL / PostgreSQL by @kyleconroy in #2463
- docs: Add a description to the document for cases when a query result has no rows by @n3xem in #2462
- feat: add basic parsing of boolean flag query metadata annotations by @andrewmbenton in #2464
- feat(vet): Introduce a query annotation to opt out of sqlc vet rules by @andrewmbenton in #2474
- fix(vet): report an error when a query is unpreparable, remove dead code by @andrewmbenton in #2486
- build(deps): bump pygments from 2.7.4 to 2.15.0 in /docs by @dependabot in #2485
- build(deps): bump github.com/jackc/pgconn from 1.14.0 to 1.14.1 by @dependabot in #2483
- feat(vet): Add output from
EXPLAIN ...
for queries to the CEL program environment by @andrewmbenton in #2489 - docs: update copyright and author by @andrewmbenton in #2490
- fix: sqlite log by @mcdoker18 in #2488
- build(deps): bump github.com/google/cel-go from 0.16.0 to 0.17.1 by @dependabot in #2484
- docs: Check Python dependencies via dependabot by @kyleconroy in #2497
- build(deps): bump idna from 2.10 to 3.4 in /docs by @dependabot in #2499
- build(deps): bump packaging from 20.9 to 23.1 in /docs by @dependabot in #2498
- build(deps): bump pygments from 2.15.0 to 2.15.1 in /docs by @dependabot in #2500
- fix(engine/sqlite): support for repeated table_option by @orisano in #2482
- test: Add profiles to docker compose by @kyleconroy in #2503
- Add example sqlc.yaml for migration parsing by @samfweb in #2479
- fix(engine/sqlite): added function to convert cast node by @orisano in #2470
- build(deps): bump certifi from 2022.12.7 to 2023.7.22 in /docs by @kyleconroy in #2504
- fix(engine/sqlite): fixed to be able to find relation from WITH clause by @orisano in #2444
- build(deps): bump sphinx from 4.4.0 to 6.1.0 in /docs by @kyleconroy in #2505
- build: Add psql and mysqlsh to devenv by @kyleconroy in #2507
- fix(sql/catalog): Support pg_dump output by @kyleconroy in #2508
- docs: small updates by @andrewmbenton in #2506
- fix(engine/sqlite): fixed IN operator precedence by @orisano in #2428
- fix(engine/sqlite): fix table_alias rules by @orisano in #2465
- fix(engine/sqlite): fix join_operator rule by @orisano in #2434
- fix(vet): clean up unnecessary
prepareable()
func and a var name collision by @andrewmbenton in #2509 - Clarify option package support by @johanbrandhorst in #2513
- fix(vet): Split vet messages out of codegen.proto by @kyleconroy in #2511
- build(deps): bump urllib3 from 1.26.5 to 2.0.4 in /docs by @dependabot in #2516
- build(deps): bump chardet from 4.0.0 to 5.1.0 in /docs by @dependabot in #2517
- build(deps): bump snowballstemmer from 2.1.0 to 2.2.0 in /docs by @dependabot in #2519
- build(deps): bump pytz from 2021.1 to 2023.3 in /docs by @dependabot in #2520
- build(deps): bump sphinxcontrib-htmlhelp from 2.0.0 to 2.0.1 in /docs by @dependabot in #2518
- fix missing unsigned param by @hiroebe in #2522
- feat(debug): add debug flag and docs for dumping vet rule variables by @andrewmbenton in #2521
- Fix code geneation for sqlc.slice by @SoMuchForSubtlety in #2431
- build(deps): bump pyparsing from 2.4.7 to 3.1.0 in /docs by @dependabot in #2530
- build(deps): bump alabaster from 0.7.12 to 0.7.13 in /docs by @dependabot in #2526
- feat(sqlite): virtual tables and fts5 supported by @mcdoker18 in #2531
- fix(vet): query.cmd was always set to ":" by @thokra-nav in #2525
- build(docs): Ignore updates for sphinx by @kyleconroy in #2532
- build(deps): bump babel from 2.9.1 to 2.12.1 in /docs by @dependabot in #2527
- build(deps): bump sphinxcontrib-applehelp from 1.0.2 to 1.0.4 in /docs by @dependabot in #2533
- chore!: Rename kyleconroy/sqlc to sqlc-dev/sqlc by @kyleconroy in #2523
- docs: Point GitHub links to new repository location by @kyleconroy in #2534
- fix(engine/sqlite): To lowercase ast.ResTarget.Name by @orisano in #2433
- chore(proto): reformat protos using
buf format -w
by @andrewmbenton in #2536 - build(deps): bump google.golang.org/grpc from 1.56.2 to 1.57.0 by @dependabot in #2535
- fix(compiler): correctly validate alias in order/group by clauses for joins by @andrewmbenton in #2537
- chore: Update FEATURE_REQUEST.yml to include SQLite engine option by @andrewmbenton in #2540
- feat(sql/catalog): Support ALTER TABLE IF EXISTS by @kyleconroy in #2542
- feat(mysql): Implement cast function parser by @RadhiFadlillah in #2473
- feat(mysql): :copyfrom support via LOAD DATA INFILE by @kyleconroy in #2545
- feat(postgresql): Add support for PostgreSQL multi-dimensional arrays by @colli173 in #2338
- fix(codegen/golang): fix sqlc.embed to work with pq.Array wrap by @orisano in #2544
- refactor(compiler): remove some duplicate code by @andrewmbenton in #2546
- build(deps): bump pyparsing from 3.1.0 to 3.1.1 in /docs by @dependabot in #2547
- chore: Finish migration to sqlc-dev/sqlc by @kyleconroy in #2548
- feat(vet): Add default query parameters for explain queries by @kyleconroy in #2543
- feat(cmd/sqlc): Bump version to 1.20.0 by @kyleconroy in #2549
New Contributors
- @peterwillis made their first contribution in #2448
- @n3xem made their first contribution in #2462
- @samfweb made their first contribution in #2479
- @hiroebe made their first contribution in #2522
- @SoMuchForSubtlety made their first contribution in #2431
- @thokra-nav made their first contribution in #2525
- @RadhiFadlillah made their first contribution in #2473
- @colli173 made their first contribution in #2338
Full Changelog: v1.19.1...v1.20.0
v1.19.1
What's Changed
- chore: replace codegen, test and docs references to github.com/tabbed repos by @andrewmbenton in #2418
- build(deps): bump google.golang.org/grpc from 1.56.1 to 1.56.2 by @dependabot in #2415
- Fix: Update sqlc/db-prepare command name in docs by @ngutierrez3 in #2426
- Update ci.yml with bumped go version for vulncheck by @andrewmbenton in #2439
- Update devenv.nix to add pkgs.gopls by @andrewmbenton in #2438
- Update go.mod to match go mod tidy output by @andrewmbenton in #2440
- build(deps): bump golang from 1.20.5 to 1.20.6 by @dependabot in #2437
- build: Pin Go to 1.20.6 by @kyleconroy in #2441
- fix: fix rewrite to traverse Sel in ast.In by @orisano in #2414
- build(deps): bump github.com/jackc/pgx/v5 from 5.4.1 to 5.4.2 by @dependabot in #2436
- Add an endtoend test that covers the case referenced in #2403 by @andrewmbenton in #2442
- fix(compiler): Validate UNION ... ORDER BY by @kyleconroy in #2446
- fix(golang): Prevent duplicate enum output by @kyleconroy in #2447
- fix(postgres): prevent panics when encountering unexpected ast nodes in range function lists by @andrewmbenton in #2449
- cmd/sqlc: Bump version to v1.19.1 by @kyleconroy in #2455
- docs: Use downloads.sqlc.dev for install links by @kyleconroy in #2456
New Contributors
- @ngutierrez3 made their first contribution in #2426
Full Changelog: v1.19.0...v1.19.1
v1.19.0
What's new
sqlc vet
sqlc vet
runs queries through a set of lint rules.
Rules are defined in the sqlc
configuration file. They consist of a name, message, and a Common Expression Language (CEL) expression. Expressions are evaluated using cel-go. If an expression evaluates to true
, an error is reported using the given message.
While these examples are simplistic, they give you a flavor of the types of rules you can write.
version: 2
sql:
- schema: "query.sql"
queries: "query.sql"
engine: "postgresql"
gen:
go:
package: "authors"
out: "db"
rules:
- no-pg
- no-delete
- only-one-param
- no-exec
rules:
- name: no-pg
message: "invalid engine: postgresql"
rule: |
config.engine == "postgresql"
- name: no-delete
message: "don't use delete statements"
rule: |
query.sql.contains("DELETE")
- name: only-one-param
message: "too many parameters"
rule: |
query.params.size() > 1
- name: no-exec
message: "don't use exec"
rule: |
query.cmd == "exec"
Database connectivity
vet
also marks the first time that sqlc
can connect to a live, running database server. We'll expand this functionality over time, but for now it powers the sqlc/db-prepare
built-in rule.
When a database is configured, the sqlc/db-prepare
rule will attempt to prepare each of your queries against the connected database and report any failures.
version: 2
sql:
- schema: "query.sql"
queries: "query.sql"
engine: "postgresql"
gen:
go:
package: "authors"
out: "db"
database:
uri: "postgresql://postgres:password@localhost:5432/postgres"
rules:
- sqlc/db-prepare
To see this in action, check out the authors example.
Please note that sqlc
does not manage or migrate your database. Use your migration tool of choice to create the necessary database tables and objects before running sqlc vet
.
Omit unused structs
Added a new configuration parameter omit_unused_structs
which, when set to true, filters out table and enum structs that aren't used in queries for a given package.
Suggested CI/CD setup
With the addition of sqlc diff
and sqlc vet
, we encourage users to run sqlc in your CI/CD pipelines. See our suggested CI/CD setup for more information.
Simplified plugin development
The sqlc-gen-kotlin and sqlc-gen-python plugins have been updated use the upcoming WASI support in Go 1.21. Building these plugins no longer requires TinyGo.
What's Changed
- Fixing Document Typo by @jyono in #2236
- Update changelog.md with some minor edits by @andrewmbenton in #2235
- fix: pointers overrides skip imports in generated query files by @ludusrusso in #2240
- fix: CASE-ELSE clause is not properly parsed when a value is constant by @nozaq in #2238
- remote: use user-id/password auth by @andrewmbenton in #2262
- Feat: PostgreSQL capture correct line and column numbers for parse error by @StevenACoffman in #2289
- build(deps): bump requests from 2.25.1 to 2.31.0 in /docs by @dependabot in #2283
- build(deps): bump golang from 1.20.3 to 1.20.4 by @dependabot in #2256
- build(deps): bump google.golang.org/grpc from 1.54.0 to 1.55.0 by @dependabot in #2265
- build(deps): bump github.com/mattn/go-sqlite3 from 1.14.16 to 1.14.17 by @dependabot in #2293
- build(deps): bump golang.org/x/sync from 0.1.0 to 0.2.0 by @dependabot in #2266
- docs: Add F# community plugin by @kyleconroy in #2295
- Update bufbuild plugin references by @mfridman in #2253
- engine/sqlite: Handle untyped sqlite columns without crashing by @andrewmbenton in #2281
- feat(sqlite) add support sqlc functions by @hakobera in #2274
- feat: add supporting COMMENT ON VIEW by @orisano in #2249
- feat: to allow spaces between function name and arguments of functions to be rewritten by @orisano in #2250
- fix: fix toSnakeCase to handle input in camel case format by @orisano in #2245
- feat: add support for pgx/v5 emit_pointers_for_null_types flag by @ludusrusso in #2269
- fix(engine/sqlite): add location info to sqlite ast by @orisano in #2298
- build(deps): bump golang from 1.20.4 to 1.20.5 by @dependabot in #2301
- sqlite: fixed sqlite column type override by @mcdoker18 in #1986
- Fix hyphen in go struct names by @kyleconroy in #2305
- codegen: Use catalog's default schema by @kyleconroy in #2310
- codegen(go): Add tests for tables with dashes by @kyleconroy in #2312
- Update BUG_REPORT.yml by @kyleconroy in #2313
- fix citext resolution issues by @ryan-berger in #1629
- fix: add override tags to result struct (#1867) by @akutschera in #1887
- fix: Override types of aliased columns and named parameters by @haines in #1884
- fix: resolve duplicate fields generated when inheriting multiple tables by @ethan-xiao in #2089
- postgres: Column merging for table inheritence by @kyleconroy in #2315
- codegen(go): Strip invalid characters from table and column names by @kyleconroy in #2314
- feat(mysql): handle unsigned integers by @roccoblues in #1746
- fix: check column references in ORDER BY (#1411) by @akutschera in #1915
- Update using-go-and-pgx.rst by @teenjuna in #2318
- Support JSON tags for nullable enum structs by @mikemherron in #2121
- build: Configure dependencies via devenv.sh by @kyleconroy in #2319
- feat: Allow use of table and column aliases for table functions returning unknown types by @haines in #2156
- build: Configure dependencies via devenv.sh by @kyleconroy in #2326
- docs: Add a ReadTheDocs config file by @kyleconroy in #2327
- build(deps): bump golang.org/x/sync from 0.2.0 to 0.3.0 by @dependabot in #2328
- build(deps): bump google.golang.org/grpc from 1.55.0 to 1.56.0 by @dependabot in #2333
- fix(sqlite) fix EXISTS operator by @hakobera in #2334
- improve init command to create v2/v1 yaml file by @dangquangdon in #2335
- Update changelog.md by @kyleconroy in #2342
- fix: MySQL slice shadowing database/sql import by @LudovicDebost in #2332
- internal/config: support golang overrides for slices by @andrewmbenton in #2339
- cmd/sqlc: Show helpful output on missing subcommand by @kyleconroy in #2345
- Support for parsing REFRESH MATERIALIZED VIEW by @Jille in #2347
- Add json_tags_id_camelcase configuration option by @jwc-clinnection in #2325
- protos: Add missing field name by @kyleconroy in #2354
- python: Use latest version of sqlc-gen-python by @kyleconroy in #2355
- kotlin: Use latest version of sqlc-gen-kotlin by @kyleconroy in #2356
- build(deps): bump google.golang.org/protobuf from 1.30.0 to 1.31.0 by @dependabot in #2370
- build(deps): bump actions/checkout from 2 to 3 by @dependabot in #2357
- build: Run govulncheck on all builds by @kyleconroy in #2372
- build(deps): bump google.golang.org/grpc from 1.56.0 to 1.56.1 by @dependabot in #2358
- A few small staticcheck fixes by @Jille in #2361
- Support "LIMIT ?" in UPDATE and DELETE for MySQL by @Jille in #2365
- Add compiler support for NOTIFY a...