Proto commits in sqlc-dev/sqlc

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

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.