Proto commits in sqlc-dev/sqlc

These 82 commits are when the Protocol Buffers files have changed:

Commit:8a26713
Author:Kyle Gray
Committer:GitHub

Go codegen for ClickHouse, DuckDB, Spanner and SQL Server under database/sql (#4621) * plugin: carry the analysis core's type expression on Column The core analyzer types every column and parameter as an expression: a name, whether a value may be null, and nested arguments, so decimal(10, 2), array(array(integer)) and struct(x: integer) survive intact. The plugin request flattened that to a single type name plus not_null, is_array, array_dims, length and unsigned, which is not enough for a type mapper to tell nvarchar(max) from nvarchar(50) or to see the element of an array or the fields of a struct. Add a recursive TypeExpr message to the plugin proto and a type_expr field on Column, populated from the core's tree in the shim. It is only set when the analysis core typed the column; the legacy path leaves it unset and the flat fields stay as they were, so existing plugins keep working. When a database analyzer overrides a column's flat type in combineAnalysis, the tree no longer describes the column and is dropped. A DuckDB codegen_json case pins the shape with decimal arguments, nested arrays, a labeled struct, a map and a sized array. The existing JSON request goldens gain the new field, unset, on every column. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * codegen/golang: map ClickHouse, DuckDB, Spanner and SQL Server types The Go generator ran for the four engines the analysis core handles but knew none of their types, so every field came out as any. Add a mapper per engine that reads the column's type expression rather than the flat name, which is what lets it see the element of an array, the key and value of a map, the fields of a struct, and the type LowCardinality or SimpleAggregateFunction wraps. Each maps to the Go types the engine's database/sql driver hands back: shopspring decimals, orb geometries and pointer-typed nullable elements for clickhouse-go; duckdb.Composite, duckdb.Decimal, duckdb.Interval and duckdb.Map for duckdb-go, with a list parameter typed as the slice itself since a Composite is not accepted as an argument; the spanner package's Null types for go-sql-spanner, whose arrays decode into them; and mssql.UniqueIdentifier for go-mssqldb. The tree-reading mappers render the whole type, arrays included, so goType leaves the dimensions to them. Model columns come from the catalog, which the core path flattened, so catalog.Column now carries the expression too and the shim forwards it. The queries for these engines pass slices straight to the driver, so pq.Array wrapping is limited to PostgreSQL under database/sql, where lib/pq needs it. Import detection follows a package qualifier into map keys and values and through any number of slice and pointer prefixes. A core_types case per engine generates the analyze_types schema and queries with database/sql and pins the output; the end-to-end module gains the drivers so the generated code compiles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * codegen/golang: bind named placeholders with sql.Named, and run the new engines' examples SQL Server and Spanner name a parameter @name in the query text and ClickHouse's server-side placeholder is {name:Type}; their drivers take such an argument as sql.Named rather than by position. When every parameter of a query is named that way, pass each as sql.Named with the name the query uses. A query written with ? keeps positional arguments. Add an authors example for ClickHouse, SQL Server and Spanner beside the existing ones, and one for DuckDB in a module of its own, since its driver is cgo and the main module's builds keep cgo off. Test helpers create a database per test on the server CLICKHOUSE_SERVER_URI, MSSQL_SERVER_URI or SPANNER_SERVER_URI names and skip when none is; the DuckDB example opens a database in memory. CI runs ClickHouse and SQL Server as services, builds the end-to-end module with cgo for the DuckDB driver, and tests the DuckDB module; docker-compose gains a ClickHouse service beside the SQL Server and Spanner Omni ones for local runs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * ci: give the ClickHouse service a password so the example can reach it The ClickHouse image restricts the default user to connections from localhost unless a password is configured, and the test job reaches the service through a port mapping, so the ClickHouse example failed to authenticate. Set a password on the service and in the URI, in docker-compose too. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * examples: make the examples a module of their own, and run Spanner Omni in CI The examples' drivers were becoming dependencies of sqlc itself, and the DuckDB driver, being cgo, had to live in a module apart. Move every example into one module under examples/, which requires sqlc through a replace, so the drivers are its dependencies alone and cgo can stay on for all of it; sqlc's own go.mod loses them, and lib/pq with them, since only the examples imported it. The DuckDB example rejoins the authors example beside the others, and the test helpers for ClickHouse, SQL Server and Spanner move into the examples module, since the drivers they need are what kept them out of sqlc. The end-to-end suite skips the directory under examples that holds those helpers rather than treating it as an example. sqlc-test-setup now installs Spanner Omni from its standalone server release, checked against a pinned SHA-256, and starts a single server in the background on port 15000, so CI runs the Spanner example against it alongside the ClickHouse and SQL Server services. The Makefile and CI run the examples from their module. Drop the clearing of a column's type expression in combineAnalysis: the compiler builds a live-database analyzer only on the legacy path and returns before doing so on the core path, so the two never meet and the expression is never set where the analyzer runs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * docs: say N/A rather than Not implemented in the language support table Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * ci: run the examples in a job of their own The examples need every database sqlc supports, while sqlc's own tests need only PostgreSQL and MySQL. Split the test job in two, and let sqlc-test-setup take the databases to install and start as arguments so each job sets up what it uses. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * ci: build the end-to-end module with cgo off again The DuckDB golden imports the DuckDB driver, which is cgo, so it is left out of that build and checked by the replay suite alone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * codegen/json: leave out an unset type_expr; test-setup: install ClickHouse and SQL Server A column's type_expr is only set when the analysis core typed it, and the JSON plugin wrote every other column with an explicit null, which put a line on every column of every request the legacy path produced. Drop the member when it is unset instead, so those requests read as they did before the member existed; the goldens on the legacy path are back to what they were. sqlc-test-setup now installs and starts ClickHouse and SQL Server as well, so the examples need no service containers from CI's host. ClickHouse comes from the release tarball goldeneye pins, checked against its SHA-512 and cached where goldeneye caches it, and runs from a configuration the tool writes that gives the default user the password the tests use. SQL Server comes from Microsoft's apt repository for Ubuntu 22.04 and 24.04, set up non-interactively with the EULA accepted, and starts through systemd where there is one and in the background otherwise. The examples job in CI installs and starts every database through the tool. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * codegen/golang: name the engines with constants; ci: build the end-to-end module with cgo The end-to-end module is one of its own, so cgo there is no concern of sqlc's builds, and the DuckDB golden compiles with the rest again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * test-setup: keep the SQL Server it starts off the tool's own output A detached server holding the tool's stderr open kept anything reading the tool's output waiting after the tool had finished. Its output goes to a file of its own, the way the ClickHouse and Spanner Omni servers' does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * sqlc-test-setup: accept a successful mssql-conf setup without stat-ing its conf On a GitHub runner the tool runs as an unprivileged user, and /var/opt/mssql is readable by the mssql user only, so stat-ing /var/opt/mssql/mssql.conf failed with permission denied even though setup had completed. Treat a successful setup as installed, and when setup fails check for the configuration through sudo before deciding whether the failure was only the service start. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * codegen/json: write an unset type_expr as null again The regex that stripped the member from protojson's output was a hack around EmitUnpopulated, which has no per-field form. A column the legacy path typed now carries "type_expr": null like every other unset message field, and the goldens are regenerated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * Bind named placeholders from the compiler, scan DuckDB lists and ClickHouse nullables correctly A parameter whose placeholder names it, SQL Server's and Spanner's @name and ClickHouse's {name:Type}, is now marked by the compiler: the mssql and googlesql converters carry the name on the ParamRef as the ClickHouse one already did, the analyzer keeps it whichever use of the parameter it sees first, and the plugin Parameter gains a named field. The Go codegen reads that instead of searching the query text for "@name", which bound a CAST-wrapped @a positionally, because the analyzer had named it after the column it was compared with, and matched "@id" inside "@identity_no". A row struct is scanned into and a params struct is passed as arguments, and DuckDB wants different types for the two: a list is duckdb.Composite when scanned and a plain slice when passed. Row structs used the params form. The imports for the element of a generic type such as duckdb.Composite[[]time.Time] were also missing, and sql.Named's database/sql import reached the querier interface, which does not use it. clickhouse-go dereferences a Nullable value only when Nullable is the column's outermost type, so LowCardinality(Nullable(T)) and SimpleAggregateFunction(f, Nullable(T)) come through as pointers that a sql.Null wrapper cannot scan; they take the pointer form now. sqlc-test-setup start skips SQL Server wherever install did, rather than failing on an Ubuntu release the packages are not published for. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * plugin: pass the placeholder's name on Parameter rather than a flag The name a placeholder carries, @name or {name:Type}, is what the driver binds by, so the plugin Parameter carries it as name, collected from the query's ParamRef nodes by the compiler rather than taken from the analyzer, which also names a parameter after the function it is compared with. The Go codegen passes it to sql.Named instead of the column's name. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT * codegen/golang: bind parameters the new engines' drivers accept, and keep driver imports to those engines - The driver packages the ClickHouse, DuckDB, Spanner and SQL Server mappers draw on are imported only for those engines, and not when an override's type carries the same qualifier. A PostgreSQL numeric overridden to another package's decimal.Decimal imported shopspring's as well and did not compile. - ClickHouse parameters are typed for what clickhouse-go sends: the std driver never calls Value, and a {name:Type} placeholder is sent as text formatted from the value, so a sql.Null wrapper went out as its struct fields and a decimal, UUID, address or wide integer quoted. A nullable parameter is a pointer, and those types are strings. - DuckDB BIT scans into duckdb.Bit. A DECIMAL parameter is passed as its text and a STRUCT parameter as a map, or any when nullable, since the driver binds neither a Decimal nor a pointer to a map, and binds a nil map as a struct of nulls. - Repeated {name:Type} placeholders share one parameter, and SQL Server compares @name without regard to case, so @Name and @name are one. - A query that mixes named placeholders with positional ones, such as the ? sqlc.arg becomes, is an error: it cannot be bound either way. - The four engines reject a sql_package other than database/sql. - A catalog column's type_expr says whether it is nullable, as a result column's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KRHPAjUHm5bE8noT5ut2C5 * sqlc-test-setup: wait for SQL Server and Spanner Omni to serve, and keep interrupted installs from looking done - start waits for SQL Server's log to say it is ready even when the service is already listening, as it is once mssql-conf setup starts it through systemd, rather than returning while it recovers its databases. A server this machine does not run, such as docker-compose's, still counts once it listens. - A failed mssql-conf setup is tolerated only where there is no systemd, the one failure that leaves a usable configuration behind, and an install that stopped before setup finished reruns it rather than reporting SQL Server installed. The setup command line, which carries the sa password, is no longer logged. - Spanner Omni counts as ready once ListDatabases on its default instance succeeds, not once its port accepts a connection, which it does before the instance exists. The request is encoded by hand, so the Spanner client libraries stay out of the module. - The Omni release is unpacked in process into a directory beside where it goes and moved into place whole, so an interrupted unpack no longer leaves a launcher that looks installed. - Downloads time out after 15 minutes, and the examples job after 45; its Go cache covers the examples module's go.sum as well. - docs: say which of the new engines' types still come out as any, and how DuckDB's JSON columns are read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KRHPAjUHm5bE8noT5ut2C5 * examples: regenerate the ClickHouse authors example for pointer parameters Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KRHPAjUHm5bE8noT5ut2C5 * duckdb: make JSON a type of its own DuckDB's catalog lists JSON as a spelling of VARCHAR, so the seed made it an alias and a JSON column came out as string. But DuckDB keeps JSON apart: typeof() reports it as JSON, and duckdb-go decodes a JSON value into whatever the document holds, which only any can receive. goldeneye now asks typeof() for each alias, and seeds a spelling that DuckDB reports by its own name as a type that stands on the logical type. For JSON that is the base varchar. The DuckDB Go mapper scans JSON into any and binds a JSON parameter from its text as a string. A new duckdb_json case covers columns, parameters and json_extract, and its generated code was run against DuckDB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KRHPAjUHm5bE8noT5ut2C5 --------- Co-authored-by: Claude <noreply@anthropic.com>

Commit:205daf7
Author:Claude

plugin: pass the placeholder's name on Parameter rather than a flag The name a placeholder carries, @name or {name:Type}, is what the driver binds by, so the plugin Parameter carries it as name, collected from the query's ParamRef nodes by the compiler rather than taken from the analyzer, which also names a parameter after the function it is compared with. The Go codegen passes it to sql.Named instead of the column's name. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT

Commit:4257811
Author:Claude

Bind named placeholders from the compiler, scan DuckDB lists and ClickHouse nullables correctly A parameter whose placeholder names it, SQL Server's and Spanner's @name and ClickHouse's {name:Type}, is now marked by the compiler: the mssql and googlesql converters carry the name on the ParamRef as the ClickHouse one already did, the analyzer keeps it whichever use of the parameter it sees first, and the plugin Parameter gains a named field. The Go codegen reads that instead of searching the query text for "@name", which bound a CAST-wrapped @a positionally, because the analyzer had named it after the column it was compared with, and matched "@id" inside "@identity_no". A row struct is scanned into and a params struct is passed as arguments, and DuckDB wants different types for the two: a list is duckdb.Composite when scanned and a plain slice when passed. Row structs used the params form. The imports for the element of a generic type such as duckdb.Composite[[]time.Time] were also missing, and sql.Named's database/sql import reached the querier interface, which does not use it. clickhouse-go dereferences a Nullable value only when Nullable is the column's outermost type, so LowCardinality(Nullable(T)) and SimpleAggregateFunction(f, Nullable(T)) come through as pointers that a sql.Null wrapper cannot scan; they take the pointer form now. sqlc-test-setup start skips SQL Server wherever install did, rather than failing on an Ubuntu release the packages are not published for. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT

Commit:5802484
Author:Claude

plugin: carry the analysis core's type expression on Column The core analyzer types every column and parameter as an expression: a name, whether a value may be null, and nested arguments, so decimal(10, 2), array(array(integer)) and struct(x: integer) survive intact. The plugin request flattened that to a single type name plus not_null, is_array, array_dims, length and unsigned, which is not enough for a type mapper to tell nvarchar(max) from nvarchar(50) or to see the element of an array or the fields of a struct. Add a recursive TypeExpr message to the plugin proto and a type_expr field on Column, populated from the core's tree in the shim. It is only set when the analysis core typed the column; the legacy path leaves it unset and the flat fields stay as they were, so existing plugins keep working. When a database analyzer overrides a column's flat type in combineAnalysis, the tree no longer describes the column and is dropped. A DuckDB codegen_json case pins the shape with decimal arguments, nested arrays, a labeled struct, a map and a sized array. The existing JSON request goldens gain the new field, unset, on every column. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT

Commit:977ac6d
Author:Kyle Gray
Committer:GitHub

Remove --remote and --no-remote flags (#4417) Removes the --remote/--no-remote flags, the remoteGenerate() codegen path, and the now-unused internal/remote gRPC client. The cloud.* config block, SQLC_AUTH_TOKEN, QuickDB, and managed databases are unaffected. Co-authored-by: Claude <noreply@anthropic.com>

Commit:64313a6
Author:Kyle Gray
Committer:GitHub

feat(verify): Add new command to verify queries and migrations (#2986) We've renamed the upload sub-command to push. Using upload is supported for now, but please switch over to using 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 protobuf message we pass to codegen plugins. We now pass along annotations for 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. verify The verify command, building on top of the push command, ensures migrations are safe to deploy. Verify sends 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.

The documentation is generated from this commit.

Commit:988b9d5
Author:Kyle Conroy

add default go package

The documentation is generated from this commit.

Commit:d477b9f
Author:Kyle Conroy

feat(push): Include different information when uploading archives

Commit:4507ede
Author:Andrew Benton
Committer:GitHub

feat(plugin): Use gRPC interface for codegen plugin communication (#2930) * feat(plugin): Use gRPC interface for codegen plugin communication * rename proto rpc service and messages * make invoke methods more generic * remove vtproto and add regular grpc buf plugin

Commit:d9e233e
Author:Kyle Gray
Committer:GitHub

feat(codegen): Remove Go specific overrides from codegen proto (#2929) Remove overrides and rename from the codegen.proto definition. Replace them with plugin-specifc global options defined in the `options` block. Defer validation of this configuration to the plugin itself. --------- Co-authored-by: Andrew Benton <andrew@sqlc.dev>

Commit:bcbe477
Author:Andrew Benton

attempt to do a better job passing plugin-specific override information

Commit:41343ab
Author:Andrew Benton
Committer:Andrew Benton

add back the overrides list

Commit:3853612
Author:Andrew Benton
Committer:Andrew Benton

refactor: Remove `ParsedGoType` from codegen.proto, pass in opts as JSON The `ParsedGoType` configuration only applies to Go, so we remove it from the codegen plugin proto and instead pass the configuration as JSON to be unmarshaled by the codegen/golang package like other options. Eventually we will need to push all of the validation of overrides from internal/config into the codegen/golang package, but that's a fair bit of work so I didn't push it here. Aside from the proto change, which is obviously important, the other meaningful change is to generate.go on line 421, and the function implementation in shim.go. The types in opts/override.go are just recreations of what the plugin proto types were.

Commit:11a82f0
Author:Kyle Gray
Committer:GitHub

feat(analyzer): Cache query analysis (#2889) * feat(analyzer): Cache query analysis When using managed databases, cache the query analysis if the query, schema and configuration file hasn't change. Also take into account the version of sqlc. Analysis can only be cached for managed databases as we can't know if a connected database has been changed.

Commit:c5668ff
Author:Andrew Benton

refactor(codegen/go): Remove `rename` field from codegen proto Prefer instead to pass the rename map to the internal golang codegen plugin via `options`. Also pull golang options into a subpackage.

Commit:669a487
Author:Kyle Gray
Committer:GitHub

feat(codegen): Include plugin information (#2846) * feat(codegen): Include plugin information Include the configured plugin's env, name, sha256 and URL

Commit:5ef20c6
Author:Andrew Benton
Committer:GitHub

refactor(codegen): Remove golang and json settings from plugin proto (#2822) * refactor(codegen): remove golang and json settings from plugin proto In order to simplify the codegen plugin proto, I've removed the Go and JSON plugin settings and instead pass those settings encoded as JSON to their respective plugins. * clean up proto * update sqlc-gen-json tests * put json plugin settings in `PluginOptions`

Commit:7dc0e7c
Author:Hyuga
Committer:GitHub

feat(codegen): Support setting Go build tags (#2012) (#2807) * feat(codegen): add support for build tags (#2012) * Update docs/reference/config.md * Update internal/codegen/golang/gen.go --------- Co-authored-by: Kyle Gray <kyle@conroy.org>

Commit:33398b7
Author:XanderAtGoingDutch
Committer:GitHub

feat(config): Enables the configuration of copyfrom.go similar to quierer and friends (#2727) * enables the configration of copyfrom.go similar to quierer and friends * adds a copyfrom to the output_file_name tests that support it --------- Co-authored-by: xander <xander@backbonesystems.nl>

Commit:3b48228
Author:Kyle Gray
Committer:GitHub

chore: Finish migration to sqlc-dev/sqlc (#2548)

Commit:3c9ef73
Author:Connor Collins
Committer:GitHub

feat(postgresql): Add support for PostgreSQL multi-dimensional arrays (#2338) This PR adds support for generating model fields from multi-dimensional postgresql array columns. The approach here is to pass around an additional column attribute array_bounds representing the dimensions of the postgres array column. When generating code, the array_bounds is checked along is_array to determine the dimensions of the resulting struct field. Would be happy to hear alternative approaches or solutions here as well. https://www.postgresql.org/docs/14/arrays.html Fixes issue: #1494 Replaces #1651 #2308 #2309

Commit:5b3e10e
Author:Andrew Benton
Committer:GitHub

chore(proto): reformat protos using `buf format -w` (#2536)

Commit:205c55d
Author:Kyle Gray
Committer:GitHub

fix(vet): Split vet messages out of codegen.proto (#2511)

Commit:fc99f20
Author:Andrew Benton
Committer:GitHub

feat(vet): Add output from `EXPLAIN ...` for queries to the CEL program environment (#2489) * A working prototype of sqlc vet with explain output * Some improvements to sqlc vet with explain * Clean up the PostgreSQLExplain proto message * Improve vet handling of MySQL explain output * Add a few more fields to the MySQLExplain proto message * Wrap a little more context around CEL programs in vet rules * Use proto messages for postgres and mysql cel env vars * Introduce SQLCDEBUG=dumpexplain=1 * Cleaning up a little * Adding some documentation for sqlc vet with `EXPLAIN ...` output * Disable triggering MySQL explain vet rule in authors example

Commit:3e0fca0
Author:Kyle Conroy
Committer:GitHub

feat(cmd/sqlc): Add the vet subcommand (#2344) This is a proposal to add a new subcommand that runs queries through a set of lint rules. Rules Rules are defined in the configuration file. They consist of a name, message, and an expression. If the expression evaluates to true, an error is reported. These expressions are evaluated using cel-go. Each expression has access to a query object, which is defined as the following struct: --------- Co-authored-by: Kyle Conroy <kyle@sqlc.dev>

Commit:c30b56a
Author:Kyle Conroy
Committer:Kyle Conroy

cmd/vet: Create a separate config struct

Commit:bf4db61
Author:Kyle Conroy
Committer:Kyle Conroy

cmd/sqlc: Add the vet subcommand

Commit:eceac40
Author:Andrew Benton
Committer:GitHub

feat(internal/codegen/golang): omit unused structs from output (#2369) * internal/codegen/golang: omit unused structs from output * internal/codegen/golang: modify omit_unused_structs behavior to correctly handle nullable enum types

Commit:da6fe0a
Author:Kyle Conroy
Committer:GitHub

protos: Add missing field name (#2354) * buf: Add buf.yaml and buf.lock * protos: Add missing json_tags_id_uppercase proto field * Verify buf actions

Commit:9b9a2b6
Author:Dennis Schön
Committer:GitHub

feat(mysql): Support unsigned integers (#1746) * config: Target overrides at unsigned columns --------- Co-authored-by: Kyle Conroy <kyle@conroy.org>

Commit:99ecfff
Author:Andrew Haines
Committer:GitHub

fix: Override types of aliased columns and named parameters (#1884) Signed-off-by: Andrew Haines <andrew@haines.org.nz>

Commit:8ed8493
Author:Connor

Merge branch 'main' of https://github.com/kyleconroy/sqlc into feature/pg-multi-dim-arrays

Commit:0cc1aad
Author:Jille Timmermans
Committer:GitHub

Allow sql_driver: "github.com/go-sql-driver/mysql" (#2219) In preparation of #2179 for LOAD DATA LOCAL INFILE

Commit:fc5ef8e
Author:Connor

Merge branch 'main' of https://github.com/kyleconroy/sqlc into feature/pg-multi-dim-arrays

Commit:3872990
Author:Andrew Benton
Committer:GitHub

feat: Add remote execution for codegen (#2214)

Commit:1ac031e
Author:Connor

fix merge conflicts

Commit:e5d4fba
Author:Jordan Pittier
Committer:GitHub

Customizable batch output file name (add OutputBatchFileName field) (#2178) * Customizable batch output file name (add OutputBatchFileName field) This commit adds the possibility to customize the batch output file name. Example configuration: ``` version: "1" packages: - name: db path: internal/db queries: internal/db schema: migrations engine: postgresql output_batch_file_name: batch_gen.go output_models_file_name: model_gen.go ``` * test: Add tests for new batch filename config --------- Co-authored-by: Kyle Conroy <kyle@conroy.org>

Commit:b4d2e91
Author:Cristóbal Gómez
Committer:GitHub

feat(Go):Add query_parameter_limit conf to codegen (#1558) * feat(Go):Add query_parameter_limit conf to codegen * Fix nil pointer reference * Allow query_parameter_limit to be zero * resolve conversation * remove qpl check * docs: Remove duplicate config entry --------- Co-authored-by: go-mez <cristobal.gomez@mercadolibre.cl> Co-authored-by: Kyle Conroy <kyle@conroy.org>

Commit:c7c6a36
Author:Nick Jackson
Committer:GitHub

feat: add `sqlc.embed` to allow model re-use (#1615) * add sqlc.embed * only allow alias or table name in sqlc.embed() * add tests * regenerate other tests * Fix codegen.json tests --------- Co-authored-by: Kyle Conroy <kyle@conroy.org>

Commit:a8477b8
Author:Jille Timmermans
Committer:GitHub

Add sqlc.slice() to support IN clauses in MySQL (#695) (#1816) This feature (currently MySQL-specific) allows passing in a slice to an IN clause. Adding the new function sqlc.slice() as opposed to overloading the parsing of "IN (?)" was chosen to guarantee backwards compatibility. SELECT * FROM tab WHERE col IN (sqlc.slice("go_param_name")) This commit is based on https://github.com/kyleconroy/sqlc/pull/1312 by Paul Cameron. I just rebased and did some cleanup. Co-authored-by: Paul Cameron <cameronpm@gmail.com>

Commit:a3bc887
Author:Connor

fix merge conflicts

Commit:4837b07
Author:Kyle Conroy
Committer:GitHub

build: Fix conflicts from pointer configuration (#1950)

Commit:27fffbf
Author:Nick Bruun
Committer:GitHub

Implement emission of pointer types for nullable columns. (#1571) Co-authored-by: Kyle Conroy <kyle@conroy.org>

Commit:7130e10
Author:Kyle Conroy
Committer:GitHub

codegen: Remove built-in Python support (#1936)

Commit:44df94b
Author:Kyle Conroy
Committer:GitHub

codegen: Remove built-in Kotlin support (#1935) * codegen: Remove build-in Kotlin support * Update language reference for docs * Mark old field as reserved

Commit:cf74be9
Author:Kyle Conroy
Committer:GitHub

codgen: Include serialized codegen options (#1890) * codgen: Include serialized codegen options These options were already included, but not in a way that made them easy to use. We could also pass in a pointer to the existing setting document, but I think this is cleaner * Fix tests * Fix tests (again)

Commit:f5d1ad9
Author:Connor

Merge branch 'main' of https://github.com/kyleconroy/sqlc into feature/pg-multi-dim-arrays

Commit:73cbcf3
Author:danicc097
Committer:GitHub

Inflection Singular table names exclusion configuration (#1531)

Commit:1e40dc8
Author:danicc097
Committer:GitHub

Python query param limit (#1530) * python query param limit support * refactor DefaultQueryParameterLimit update pluginPythonCode unexported default limit * refactor to optional query_parameter_limit proto * 0 has no limit, <0 invalid * revert to default python qpl of 4

Commit:9e78e66
Author:Connor

Merge branch 'main' of https://github.com/kyleconroy/sqlc into feature/pg-multi-dim-arrays

Commit:0ca51b7
Author:Kyle Conroy
Committer:GitHub

feat: Process-based codegen plugins (#1578) * feat: Add support for generic process plugins * Create a new ext package * Add end-to-end test for process plugins * Put test data in the correct spot

Commit:9c2514c
Author:Kyle Conroy

Merge branch 'main' into kyle/process-plugins

Commit:304ba5d
Author:Josh Bleecher Snyder
Committer:GitHub

add support for custom Go struct tags (#1569) * internal/config: use strings.Trim{Prefix,Suffix} This is equivalent and slightly simpler. * Makefile: fix vtproto 'go install' command * internal/codegen/golang: simplify template tag condition Rather than modeling when .Tag will be empty, check directly whether .Tag is empty. This simplifies the template and reduces the number of places that must be touched when adding new sources of struct tags. * internal/codegen/golang: tweak tag formatting Rather than inserting the colon at tag construction time, insert it at tag formatting time. This makes the input look a bit more natural. This matters more, as we are about to add another, more distant, place where we insert tags. * all: add support for custom Go struct tags This change adds a new type of override: go_struct_tag. When provided for a field, it adds that struct tag to the generated code. The provided struct tag is parsed according to the standard package reflect rules, and its components are updated independently. This allows struct tag overrides to be compatible with (and optionally override) autogenerated json and db struct tags. Fixes #534 * go.mod: bump to Go 1.18 The code uses some 1.18-only features, like strings.Cut and testing.F. The CI requires Go 1.18. Since Go 1.18 is now required, reflect that in the go.mod.

Commit:bae83b6
Author:Kyle Conroy
Committer:Kyle Conroy

It works!

Commit:c33cb8e
Author:Connor

feat: pg multi dim arrays

Commit:9c3a985
Author:Josh Bleecher Snyder
Committer:GitHub

internal/codegen: add Enum.Valid and AllEnumValues (#1613)

Commit:b75b919
Author:Kyle Conroy
Committer:GitHub

feat: Add JSON "codegen" output (#1565) * feat: Add JSON codegen output

Commit:2d8175d
Author:Kyle Conroy
Committer:Kyle Conroy

build: It compiles but it does not run

Commit:04c6c90
Author:danicc097
Committer:GitHub

Pydantic models config field (#1538) * add pydantic config field * pydantic import plus test * update based on comments

Commit:3d20d04
Author:Kyle Conroy
Committer:GitHub

feat: Pass sqlc version in codegen request (#1514)

Commit:c65fd43
Author:Kyle Conroy

feat: Use buf.build to manage protoc

Commit:eb640c8
Author:stephen
Committer:GitHub

fix bug where datatype is read from (#1468)

Commit:aade087
Author:stephen
Committer:GitHub

refactor(codegen): Port Go to plugin types (#1460) * convert to spaces in proto, fix up insert_into_table * remove use of core.FQN from sameTableName

Commit:c8926c2
Author:Kyle Conroy
Committer:GitHub

refactor(codegen): Port Kotlin codegen package to use plugin types (#1416) In #1406 I ported the Python codegen to the new plugin package. This PR does the same for the Kotlin codegen.

Commit:6ceb473
Author:Kyle Conroy
Committer:GitHub

Define code generation interface via Protocol Buffers (#1406) * Define CodeGenRequest and CodeGenResponse via `proto/plugin/codegen.proto` * Move pattern matching to another package

Commit:3764929
Author:Kyle Conroy

Implement pattern matching

Commit:cc849aa
Author:Kyle Conroy

Python tests are passing

Commit:cf86d86
Author:Kyle Conroy

Try some more things

Commit:c84a17f
Author:Kyle Conroy

First pass at finished shim

Commit:3825d3a
Author:Kyle Conroy

More progress

Commit:ee3f21f
Author:Kyle Conroy

Make fmt

Commit:bf2afc7
Author:Kyle Conroy

First pass at the plugin proto files

Commit:7b64ec5
Author:Kyle Conroy

More progres... maybe?

Commit:c55ca7f
Author:Kyle Conroy

More changes

Commit:75d7e55
Author:Kyle Conroy

go fmt code

Commit:26bb26e
Author:Kyle Conroy

Generate a bit more code

Commit:a1f4e0e
Author:Kyle Conroy

Add a few builders

Commit:1b45842
Author:Kyle Conroy

More nodes

Commit:f952d2a
Author:Kyle Conroy

Add class node

Commit:f1d7908
Author:Kyle Conroy

kotlin: First few AST nodes

Commit:44c8000
Author:Kyle Conroy
Committer:GitHub

feat(python): Generate query code using ASTs instead of templates (#1338)

Commit:c7a0afe
Author:Kyle Conroy
Committer:GitHub

First pass at AST-based codegen (#1333) * Generate models.py via AST * Update examples with new formatting Currently, we generate code by using Go templates. While this approached has served us well, the code generators themselves are getting more complicated and difficult to understand. Templates aren't fully typed-checked. Functionality is split across Go code and template code. I'm experimenting with a new approach, starting with Python. Instead of using templates, we'll build an AST and then print that AST to a file. I'm aiming to replicate the go/ast and go/printer packages. Lastly, the AST itself is defined via Protocol Buffers so that we can serialize the AST. This will be helpful in the future when we have plugin support.