v1.18.0 #2234
kyleconroy
announced in
Announcements
v1.18.0
#2234
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What's New
Remote code generation
Developed by @andrewmbenton
At its core, sqlc is powered by SQL engines, which include parsers, formatters,
analyzers and more. While our goal is to support each engine on each operating
system, it's not always possible. For example, the PostgreSQL engine does not
work on Windows.
To bridge that gap, we're announcing remote code generation, currently in
private alpha. To join the private alpha, sign up for the waitlist.
To configure remote generation, configure a
cloudblock insqlc.json.{ "version": "2", "cloud": { "organization": "<org-id>", "project": "<project-id>", }, ... }You'll also need to the
SQLC_AUTH_TOKENenvironment variable.When the cloud configuration exists,
sqlc generatewill default to remotegeneration. If you'd like to generate code locally, pass the
--no-remoteoption.
Remote generation is off by default and requires an opt-in to use.
sqlc.embed
Developed by @nickjackson
Embedding allows you to reuse existing model structs in more queries, resulting
in less manual serilization work. First, imagine we have the following schema
with students and test scores.
We want to select the student record and the highest score they got on a test.
Here's how we'd usually do that:
When using Go, sqlc will produce a struct like this:
With embedding, the struct will contain a model for the table instead of a
flattened list of columns.
sqlc.slice
Developed by Paul Cameron and Jille Timmermans
The MySQL Go driver does not support passing slices to the IN operator. The
sqlc.slicefunction generates a dynamic query at runtime with the correctnumber of parameters.
This feature is only supported in MySQL and cannot be used with prepared
queries.
Batch operation improvements
When using batches with pgx, the error returned when a batch is closed is
exported by the generated package. This change allows for cleaner error
handling using
errors.Is.Previously, you would have had to check match on the error message itself.
The generated code for batch operations always lived in
batch.go. This filename can now be configured via the
output_batch_file_nameconfigurationoption.
Configurable query parameter limits for Go
By default, sqlc will limit Go functions to a single parameter. If a query
includes more than one parameter, the generated method will use an argument
struct instead of positional arguments. This behavior can now be changed via
the
query_parameter_limitconfiguration option. If set to0, everygenerated method will use a argument struct.
What's Changed
SELECT NOT EXISTSby @haines in parser: Generate correct types forSELECT NOT EXISTS#1972sqliteas engine option by @aaanders in docs(config.md): addsqliteas engine option #2164sqlc.embedto allow model re-use by @nickjackson in feat: addsqlc.embedto allow model re-use #1615specifies parameter ":one" without containing a RETURNING clauseby @ihatov08 in fix:specifies parameter ":one" without containing a RETURNING clause#2173--no-remoteflag by @andrewmbenton in fix panic caused by invalid shorthand for--no-remoteflag #2218New Contributors
SELECT NOT EXISTS#1972sqliteas engine option #2164specifies parameter ":one" without containing a RETURNING clause#2173Full Changelog: v1.17.2...v1.18.0
This discussion was created from the release v1.18.0.
Beta Was this translation helpful? Give feedback.
All reactions