Generate type safe Go from SQL

Overview

sqlc: A SQL Compiler

go Go Report Card

sqlc generates type-safe code from SQL. Here's how it works:

  1. You write queries in SQL.
  2. You run sqlc to generate code with type-safe interfaces to those queries.
  3. You write application code that calls the generated code.

Check out an interactive example to see it in action.

Overview

Sponsors

sqlc development is funded by our generous sponsors, including the following companies:

If you use sqlc at your company, please consider becoming a sponsor today.

Sponsors receive priority support via the sqlc Slack organization.

Acknowledgements

sqlc was inspired by PugSQL and HugSQL.

Comments
  • SQLite support

    SQLite support

    Hi all, great works on this project. Is it possible to add SQLite support ? Right now I'm working on embedded device and often uses SQLite, so it will be awesome for me.

    enhancement future 
    opened by RadhiFadlillah 35
  • Add support for pgx

    Add support for pgx

    Get out the trumpets and ready the 21-gun salute, lib/pq is deprecated (#470). This means it's time to support it's successor, pgx.

    This will be the main tracking issue for pgx. It supersedes #28, as I have no intention of adding support for any additional PostgreSQL drivers beyond pgx.

    enhancement :books: postgresql :wrench: golang 
    opened by kyleconroy 26
  • Kotlin prototype

    Kotlin prototype

    Updated TODO:

    • [x] New config format https://github.com/kyleconroy/sqlc/issues/302
    • [x] Adds CI with tests for authors https://github.com/mightyguava/sqlc/pull/2
    • [x] Tests for booktest and ondeck https://github.com/mightyguava/sqlc/pull/4
    • [x] move ktgen.go to kotlin/gen.go https://github.com/mightyguava/sqlc/pull/3
    • [x] Rewrite $1 to ? in query parsing instead of with a HACK in code generation https://github.com/mightyguava/sqlc/pull/5
    • [x] Get some Kotlin folks to review generated code https://github.com/mightyguava/sqlc/pull/6
    • [ ] Support MySQL (probably needs to wait for experimental MySQL parser to stabilize a bit)

    I wanted to learn more about how sqlc works, so I took a stab at https://github.com/kyleconroy/sqlc/issues/287 anyways to see how hard it would be.

    Here's a prototype implementation for Kotlin. It's pretty rough around the edges but tests pass, and I was able to generate and compile all of the existing examples in Kotlin. authors has tests written in Kotlin to confirm that the generated code works. I haven't gotten to the rest. The sqlc codebase is pretty easy to work in! I'm impressed.

    I basically just copied gen.go into ktgen.go and renamed all the functions. It should really be its own package, but that can come if this PR actually has a chance of getting merged 😄While the code follows the same patterns as the Go generator, there were enough changes that I'm not sure much code reuse is possible.

    I split out the generated examples and a working gradle project because it would pollute this PR too much. They can be viewed here: https://github.com/mightyguava/sqlc/pull/1

    Things that work:

    • Primitives
    • NULL primitives
    • Generating schema, param, and return classes
    • one/many/exec queries

    Things that compile but I haven't tested:

    • Enums
    • Dates
    • NULLS for these types
    • Arrays
    • execRow queries

    Things that don't work:

    • Type overrides - there's no fancy Scan() interface in JDBC to support arbitrary types, so this'll require generating code to call Adapter classes for individual types. Not hard, probably, just didn't seem worthwhile exploring in a prototype
    • JSON tags - no such thing in Java/Kotlin
    • MySQL - that part of the codebase seems to be iterating rapidly, so I decided to just look at Postgres for now.

    Things that work differently:

    • Numbered parameters - JDBC seems to only support ? as placeholders. I had to write a HACK to convert things like $1 to ?. This is buggy and terrible. It also means that you can't use $1 multiple times in the same query to reference the same value. If the AST was available in the generator part then I can probably figure out how to do something better.
    • I only generate a single QueriesImpl.kt for the queries instead one for each sql file. This is because you can't have a class span multiple files in Kotlin.
    • Prepared statements - According to both JDBC and Postgres JDBC Driver docs, prepared statements are implicitly cached, so the EmitPreparedQueries option is likely unneeded here.

    Things to think about:

    • The code is in Kotlin, meaning Java projects can use it, but they need to have the Kotlin compiler. An alternative is to have sqlc just generate a self-contained module that will produce a jar for the project to depend on. I could have generated Java instead, but that would have resulted in at least 5X more generated LOC of mostly boilerplate (though I guess technically everything sqlc generates is boilerplate). I also just don't like writing Java.
    • Remove the interface option, make it required: Unlike Go, interfaces are basically mandatory in the JVM if you want to do proper unit testing. You can't just create interfaces for arbitrary classes.
    • I haven't actually spent that much time working with JDBC before, so some of the generated code could be questionable. More tests will help tell!

    Please take a look! While I'd love for this code to get merged, I understand if you don't want to take on the additional maintenance burden that another language would add. Though, I wouldn't mind helping to maintain it.

    opened by mightyguava 23
  • Fix complex packages import paths

    Fix complex packages import paths

    EDIT Please skip directly to this reply as none of what I made matters anymore since I found another import path case which fails with this current PR.

    See #462 and #255

    Attempting to fix the parsing of complex package names by leveraging regex capabilities to capture the relevant parts.

    After smashing my head for an hour I asked for help on Reddit, details of the regex expression can be found here, credits for the regex go to /u/Lee_Dailey.

    I've also added the relevant test entries which used to fail and now they pass.


    Notes

    I've left the original code as commented out for reference, it should be removed if the PR is to be accepted to avoid polluting the code with unnecessary lines.

    The regex expression can be easily batch tested here to ensure it satisfies package import names, I am not aware of any other strange import path other than gopkg.in/guregu/null.v3/zero. To nitpick the issue we should find other packages with complex import paths. I can't guarantee that this will work with every package ever.

    Two assumptions on fully qualified names have been made to build the regex:

    1. A type name is always in the form of pkgName.TypeName
    2. The import path ends with the rightmost forward slash

    This led to formulate these two regex:

    • To match a package type: match everything backwards from the end of the string to the first encountered forward slash /
    • To match a package name: match everything forward from the start of the string till the last dot found
    opened by maxiride 17
  • RFC: nullability (and other metadata) for input arguments / parameters to a query

    RFC: nullability (and other metadata) for input arguments / parameters to a query

    What do you want to change?

    Kudos Before I start, I wanted to give a huge kudos for sqlc - I love it. As a backend developer who knows SQL very well, I fight every single ORM I have used trying to do any SQL more complicated than CRUD. Thank you for creating this.

    Background I use sqlc alongside Postgres, as sort of a foreign function interface to SQL. I manage a PostgreSQL database with about 100 different tables and working in Typescript and Go to support every stage of solar operations for Bright. We do not currently use sqlc at Bright - but I do use it personally, but I am evaluating it Bright as well.

    The types of problems I work on are not always CRUD-y (though sqlc works really well if they are). And the challenge I am facing is that SQL is a little less-expressive than the target languages in some cases, and therefore using sqlc as a FFI is a little clunky. A quick glance through the some open issues, shows that "nullability" is one of those deficiencies. sqlc does its best to always "do the right thing" and that has gotten it very far indeed. But I think a simple change can give developers full control, and allow for sqlc to keep getting smarter (better interred mappings / types).

    Say for example, instead of finding a really good GeoJSON library in my target language, I wanted to rely on PostGIS.

    - name: WKBToGeoJSON :one
    select ST_AsGeoJSON(ST_GeomFromWKB(sqlc.arg('wkb_bytes'))::text as output;
    

    I would love for this Go code to be generated:

    func (q *Queries) WKBToGeoJSON(ctx context.Context, db DBTX, wkbBytes []byte) (string, error) {
        // ...
    }
    

    Or perhaps a more common use case, partial updates

    -- name: EditThing :exec
    update thing
    set
      name = coalesce(sqlc.arg('name'), name),
      description = coalesce(sqlc.arg('description'), description),
      status = coalesce(sqlc.arg('status'), status)
    where thing.id = sqlc.arg(id)
    
    -- name, description and status are all nullable arguments, id is not.
    

    Proposal I think sqlc should expose a way (like overrides) in the query itself to control aspects of the generated code in the target languages.

    Allow sqlc.arg(name) to accept more variadic arguments (similar to jsonb_build_object) to build up string key, and json value pairs of "configuration" for that arguments. I think sqlc itself should not really know too much about the semantics of these key/value pairs, and just pass them along to the code generators in the target language.

    -- name: EditThing :exec
    update thing
    set
      name = coalesce(sqlc.arg('new_name', 'nullable', true, 'type', 'string'), name),
      description = coalesce(sqlc.arg('description', nullable, true), description),
      status = coalesce(sqlc.arg('status', 'nullable', true), status)
    where thing.id = sqlc.arg(id)
    

    This also allows the developer to control the API interface much better, even if the database is a little wacky. Imagine if there was a column name that was nullable for historical reasons, but any new insert to name it should be non null. sqlc should support that use case too.

    I am not a super-polyglot, but if there were a C++ backend for sqlc, you probably wouldn't just want nullable but also maybe an option for the type of pointer that should be generated raw pointer? std::shared_ptr? std::unique_ptr? boost::? std::optional ?

    -- name: GetThingForCpp :one
    select
      id,
      first_name,
      last_name,
      sqlc.output(concat(first_name, ' ', last_name), 'nullable', false, 'ref_counted', true) as display_name
    where ....
    

    This is very similar to overrides, but on a query-by-query basis, and expressed directly in SQL instead of away from the code in a config file.

    Implementation I got pretty far along in the implementation, and I'd be happy to push it all the way through - but I hit a big snag at the SQL rewriting. Rewriting the AST is no big deal (and I had the code working for that). But the way in which sqlc rewrites the original source seems to be engine independent, and a little hacky. Performing the source rewrites with an AST "deparse" (like in pg_query_go) would solve this with almost no problem. Or if the AST has more source location info in it (not just a start location, but also an end location), that might work too. But this seemed like a bigger refactor, and I wanted to get feedback on it first.

    I'd love to know your thoughts @kyleconroy and from the general sqlc community too. I'd be happy to help and make this a reality.

    What database engines need to be changed?

    PostgreSQL, MySQL

    What programming language backends need to be changed?

    No response

    enhancement triage 
    opened by skabbes 15
  • Update configuration structure to support multiple languages

    Update configuration structure to support multiple languages

    The current version of the configuration file can't support multiple languages. Packages have Go-specific settings that do not apply to other languages.

    enhancement 
    opened by kyleconroy 15
  • Feat/nullable enums

    Feat/nullable enums

    With this PR now custom Enums have a nullable structure like all the sql.NullXXXX

    The Null structure is generated for every Enum. When enums are present on the model we import database/sql/driver The database type matching is a little bit dirty I think something better can be done, let me know if you have an idea.

    Also, how should I go about creating tests for this?

    opened by sbres 14
  • Failing to install sqlc v1.5.0 / latest

    Failing to install sqlc v1.5.0 / latest

    Issue

    go install github.com/kyleconroy/sqlc/cmd/sqlc seems to be failing due to dolphin changes

    How to reproduce

    As there are some C dependencies in sqlc, we have the following target on our Makefile:

    install-generators:
    	# more tools...
    	tmp_dir=sqlc-$(shell date +'%s') && mkdir -p /tmp/$$tmp_dir && cd /tmp/$$tmp_dir && go mod init tmp && GO11MODULE=on go install github.com/kyleconroy/sqlc/cmd/sqlc && cd - # it has C dependencies that would be a headache using go mod vendor
    

    But now it crashes with the following error:

    go: creating new go.mod: module tmp
    go: finding module for package github.com/kyleconroy/sqlc/cmd/sqlc
    go: found github.com/kyleconroy/sqlc/cmd/sqlc in github.com/kyleconroy/sqlc v1.5.0
    # github.com/kyleconroy/sqlc/internal/engine/dolphin
    /Users/brunosilva/go/pkg/mod/github.com/kyleconroy/[email protected]/internal/engine/dolphin/convert.go:197:13: n.Schema undefined (type *"github.com/pingcap/parser/ast".FuncCallExpr has no field or method Schema)
    /Users/brunosilva/go/pkg/mod/github.com/kyleconroy/[email protected]/internal/engine/dolphin/convert.go:216:14: n.Offset undefined (type *"github.com/pingcap/parser/ast".FuncCallExpr has no field or method Offset)
    

    Solution for now:

    We've changed the script to download a specific version for now

    install-generators:
    	# more tools...
    	tmp_dir=sqlc-$(shell date +'%s') && mkdir -p /tmp/$$tmp_dir && cd /tmp/$$tmp_dir && go mod init tmp && go mod edit -require github.com/kyleconroy/[email protected] && go install github.com/kyleconroy/sqlc/cmd/sqlc && cd - # it has C dependencies that would be a headache using go mod vendor
    

    EDIT: Above solution as a bash/shell script (above one is for Makefile):

    tmp_dir=sqlc-$(date +'%s') && \
    mkdir -p /tmp/$tmp_dir && \
    cd /tmp/$tmp_dir && \
    go mod init tmp && \
    go mod edit -replace github.com/pingcap/parser=github.com/kyleconroy/[email protected] && \
    go get github.com/kyleconroy/sqlc/cmd/[email protected] && \
    cd - # it has C dependencies that would be a headache using go mod vendor
    
    bug documentation upstream 
    opened by brunoluiz 13
  • syntax error at or near

    syntax error at or near "$"

    Copying the 25 line sample config exactly as shown, pasting it into a file, and running it with sqlc compile or sqlc generate leaves me with the following errors:

    test.sql:9:15: syntax error at or near "$"
    test.sql:8:1: failed to parse query leading comment
    test.sql:19:5: syntax error at or near "$"
    test.sql:20:1: syntax error at or near "2"
    test.sql:25:14: syntax error at or near "$"
    

    I tried with an sqlc init YAML file and the JSON file design in https://github.com/kyleconroy/sqlc/tree/master/examples/authors.

    sqlc version: v1.2.1-devel

    documentation :books: mysql 
    opened by Xeoncross 13
  • Add pg_tables and pg_views to catalog

    Add pg_tables and pg_views to catalog

    Fixes: https://github.com/kyleconroy/sqlc/issues/1747

    Problem - I was unable to write a query against pg_timezone_names.

    Actual failing query

    select
      name,
      abbrev,
      utc_offset,
      to_char((current_timestamp at time zone name), 'HH:MI am') as current_time
    from pg_catalog.pg_timezone_names
    order by utc_offset;
    

    This because sqlc did not know about these built-in tables / views.

    Warning I tried to make sqlc-pg-gen and make regen, but I was getting slightly different output, so in this commit I only committed the changes that affected the tables, not the existing functions (which I do not know why they were changed, perhaps a different version of postgres).

    opened by skabbes 12
  • Add support for emitting pointer types for nullable columns

    Add support for emitting pointer types for nullable columns

    pgx/v4 supports passing and scanning into pointer types for nullable columns instead of using the standard library Null<Type> representation, which is super handy if you wind up interfacing a lot with, say, generated Protocol Buffer files using the proto3 optional flag.

    This PR adds a new configuration option emit_pointers_for_null_types, which, as per the documentation line added:

    If true and sql_package is set to pgx/v4, generated types for nullable types are emitted as pointers (ie. *string) instead of database/sql null types (ie. NullString). Defaults to false.

    This change would be a significant quality-of-life improvement for me, but I obviously don't know if it generally fits with the philosophy of sqlc, so consider this a suggestion and please feel free to provide any feedback (including, but not limited to bike-shedding of the choice of name for the configuration parameter, if we see this feature fit for sqlc.)

    Lastly, thanks all for building this tool. It's genuinely saved me tons of hours writing the same pesky boiler plate with limited guarantees.

    opened by nickbruun 12
  • SQLC generated files do not pass errcheck checks

    SQLC generated files do not pass errcheck checks

    Version

    1.16.0

    What happened?

    When running errcheck on files generated by sqlc (https://github.com/kisielk/errcheck), the following line makes the check fail (the error is not checked):

    	defer rows.Close()
    

    Here's the generated code:

    	rows, err := q.db.QueryContext(ctx, ..., arg.Offset, arg.Limit)
    	if err != nil {
    		return nil, err
    	}
    	defer rows.Close() // this line
    
            ...
    
    	if err := rows.Close(); err != nil { // Why do we have the same line here?
    		return nil, err
    	}
    	if err := rows.Err(); err != nil {
    		return nil, err
    	}
    	return items, nil
    

    It would be nice to change the way this line is generated (or even to remove it, as rows.Close() is called at the end of the code) to make it errcheck compliant.

    Relevant log output

    No response

    Database schema

    No response

    SQL queries

    SELECT *
    FROM organizations
    ORDER BY name
    OFFSET $1 LIMIT $2;
    

    Configuration

    version: 1
    packages:
      - path: "app/sqlc"
        name: "sqlc"
        engine: "postgresql"
        schema: "./app/sqlc/schemas/"
        queries: "./app/sqlc/queries/"
        emit_json_tags: true
        emit_interface: true
    

    Playground URL

    No response

    What operating system are you using?

    Linux

    What database engines are you using?

    PostgreSQL

    What type of code are you generating?

    Go

    bug triage 
    opened by Kilio22 0
  • syntax error at or near

    syntax error at or near "engine" In Create table sql including engine

    What do you want to change?

    Please support engine definition when creating schema create table if not exists role ( id binary(16) not null, k varchar(32) not null ) engine=InnoDB; alter table role add primary key(id);

    What database engines need to be changed?

    PostgreSQL, MySQL

    What programming language backends need to be changed?

    No response

    enhancement triage 
    opened by DennisMuchiri 0
  • Being able to mark generated files with go:build tags

    Being able to mark generated files with go:build tags

    What do you want to change?

    It could be useful to be able to emit // go:build some-tag into the golang generated files

    This way I can, for example, exclude them when running coverage tests 😇

    What database engines need to be changed?

    No response

    What programming language backends need to be changed?

    Go

    enhancement triage 
    opened by eladitzhakian 0
  • Add time.Time to override

    Add time.Time to override

    as time.Time is not a basic Go type, and the way in which override evaluates packages, trying to swap in time.Time for date causes an error to be thrown.

    opened by Ol1BoT 0
  • MySQL generator doesn't enforce existence of columns

    MySQL generator doesn't enforce existence of columns

    Version

    1.15.0

    What happened?

    I'm using sqlc with MySQL. In a query, if I use bogus field names in JOIN, WHERE or ORDER BY clauses, the code generator will not complain. It seems that field names in the SELECT clause are validated, but not anywhere else.

    Relevant log output

    No response

    Database schema

    create table t1 (
      id int(11)      not null,
      s  varchar(128) not null,
      primary key (id)    
    ) 
    ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
    
    create table t2 (
      id    int(11) not null,
      t1_id int(11) not null,
      
      primary key (id),
      key t1_id (t1_id),
      foreign key (t1_id) references t1 (id)
    )
    ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
    

    SQL queries

    -- name: Broken :many
    SELECT
      t1.*
    FROM
      t1 LEFT JOIN t2 on t1.id = t2.t1_id
    WHERE
      t1.bar = 'x' AND t2.baz = 'y'
    ORDER BY
      t1.xyz > t2.abc
    

    Configuration

    No response

    Playground URL

    https://play.sqlc.dev/p/bf880aa2e19616101663a8bf3e1a4c02a99e234d1aac598c65541e5e11823488

    What operating system are you using?

    Linux

    What database engines are you using?

    MySQL

    What type of code are you generating?

    Go

    bug triage 
    opened by andrenth 0
  • Adding the ability to change the default scheme to generate DTO and queries

    Adding the ability to change the default scheme to generate DTO and queries

    PostgreSQL allows you to store your tables in different schemas instead of the public one.

    I haven't found the solution to generate code for the tables in the schema that differs from public. So, I have created a fix to do it.

    How it works:

    1. Place your table test in the schema, for example, test.
    2. Add the option default_schema: "test" to your sqlc.yaml
    sql:
        engine: "postgresql"
        default_schema: "test"
    
    1. In your queries file type the table name with the schema
    -- name: GetTestItem :one
    select * from "test"."test" where id=$1 limit 1;
    
    opened by debugger84 1
Releases(v1.16.0)
  • v1.16.0(Nov 9, 2022)

    What's Changed

    • build(deps): bump github.com/jackc/pgconn from 1.12.1 to 1.13.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1785
    • docs: Add a getting started guide for SQLite by @utamori in https://github.com/kyleconroy/sqlc/pull/1798
    • build(deps): bump github.com/mattn/go-sqlite3 from 1.14.13 to 1.14.15 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1799
    • build(deps): bump github.com/jackc/pgx/v4 from 4.16.1 to 4.17.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1786
    • feat: Add HAVING support to MySQL by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1806
    • pg-gen: make sqlc-pg-gen the complete source of truth for pg_catalog.go by @skabbes in https://github.com/kyleconroy/sqlc/pull/1809
    • missing " by @ChrisElliotUK in https://github.com/kyleconroy/sqlc/pull/1805
    • fix(validate): sqlc.arg & sqlc.narg are not "missing" by @skabbes in https://github.com/kyleconroy/sqlc/pull/1814
    • Add pg_tables and pg_views to catalog by @skabbes in https://github.com/kyleconroy/sqlc/pull/1811
    • pg-gen: implement information_schema shema by @skabbes in https://github.com/kyleconroy/sqlc/pull/1815
    • fix: Emit correct comment for nullable enums by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1819
    • build(deps): bump github.com/jackc/pgx/v4 from 4.17.0 to 4.17.1 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1825
    • Python query param limit by @danicc097 in https://github.com/kyleconroy/sqlc/pull/1530
    • Inflection Singular table names exclusion configuration by @danicc097 in https://github.com/kyleconroy/sqlc/pull/1531
    • build(deps): bump github.com/bytecodealliance/wasmtime-go from 0.39.0 to 0.40.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1826
    • chore: Upgrade wasmtime version by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1827
    • fix: 🐛 Correctly switch coalesce() result .NotNull value by @mpyw in https://github.com/kyleconroy/sqlc/pull/1664
    • build(deps): bump github.com/jackc/pgx/v4 from 4.17.1 to 4.17.2 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1831
    • build(deps): bump golang from 1.19.0 to 1.19.1 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1834
    • fix: prevent batch infinite loop with arg length by @chrisyxlee in https://github.com/kyleconroy/sqlc/pull/1794
    • build(deps): bump github.com/google/go-cmp from 0.5.8 to 0.5.9 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1838
    • build(deps): bump github.com/lib/pq from 1.10.6 to 1.10.7 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1835
    • fix: version support in error message by @linweiyuan in https://github.com/kyleconroy/sqlc/pull/1839
    • fix: handle empty column list in postgresql select statements by @akutschera in https://github.com/kyleconroy/sqlc/pull/1843
    • fix: batch imports filter queries, update cmds having ret type by @chrisyxlee in https://github.com/kyleconroy/sqlc/pull/1842
    • fix: named params contribute to batch parameter count by @chrisyxlee in https://github.com/kyleconroy/sqlc/pull/1841
    • docs: various readability improvements by @sudomateo in https://github.com/kyleconroy/sqlc/pull/1854
    • build(deps): bump github.com/bytecodealliance/wasmtime-go from 0.40.0 to 1.0.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1857
    • chore: Bump wasmtime version to v1.0.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1869
    • Fix a typo in config.md by @mateoradman in https://github.com/kyleconroy/sqlc/pull/1876
    • Remove unnecessary AUTOINCREMENT from example by @thecashewtrader in https://github.com/kyleconroy/sqlc/pull/1891
    • codgen: Include serialized codegen options by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1890
    • build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1893
    • examples: Port Python examples to WASM plugin by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1903
    • docs: Add documentation for codegen plugins by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1904
    • [PART 1] pgx v5 support (#1823) by @mcdoker18 in https://github.com/kyleconroy/sqlc/pull/1873
    • python: Port all Python tests to sqlc-gen-python by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1907
    • compiler: Move Kotlin parameter logic into codegen by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1910
    • Update pg_query_go to 2.2.0 / libpg_query to 13-2.2.0 by @lfittl in https://github.com/kyleconroy/sqlc/pull/1921
    • build(deps): bump golang from 1.19.1 to 1.19.3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1920
    • Add docs for Kotlin / Python migration by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1929
    • Add deprecation warning for Python and Kotlin by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1930
    • python: Upgrade to sqlc-gen-python v1.0.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1932
    • Port kotlin examples to sqlc-gen-kotlin by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1931
    • docs: Update migration guides with links by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1933
    • cmd/sqlc: Bump to v1.16.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1934

    New Contributors

    • @ChrisElliotUK made their first contribution in https://github.com/kyleconroy/sqlc/pull/1805
    • @mpyw made their first contribution in https://github.com/kyleconroy/sqlc/pull/1664
    • @chrisyxlee made their first contribution in https://github.com/kyleconroy/sqlc/pull/1794
    • @linweiyuan made their first contribution in https://github.com/kyleconroy/sqlc/pull/1839
    • @sudomateo made their first contribution in https://github.com/kyleconroy/sqlc/pull/1854
    • @mateoradman made their first contribution in https://github.com/kyleconroy/sqlc/pull/1876
    • @thecashewtrader made their first contribution in https://github.com/kyleconroy/sqlc/pull/1891
    • @mcdoker18 made their first contribution in https://github.com/kyleconroy/sqlc/pull/1873
    • @lfittl made their first contribution in https://github.com/kyleconroy/sqlc/pull/1921

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.15.0...v1.16.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.16.0_darwin_amd64.tar.gz(15.46 MB)
    sqlc_1.16.0_darwin_amd64.zip(15.33 MB)
    sqlc_1.16.0_darwin_arm64.tar.gz(13.96 MB)
    sqlc_1.16.0_darwin_arm64.zip(13.87 MB)
    sqlc_1.16.0_linux_amd64.tar.gz(13.90 MB)
    sqlc_1.16.0_linux_amd64.zip(13.78 MB)
    sqlc_1.16.0_windows_amd64.tar.gz(12.02 MB)
    sqlc_1.16.0_windows_amd64.zip(11.92 MB)
  • v1.15.0(Aug 7, 2022)

    What's Changed

    • docs: Add process-based plugin docs by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1669
    • Update BUG_REPORT.yml by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1672
    • docs: Add links to downloads.sqlc.dev by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1681
    • feat: More SQL Syntax Support for SQLite by @hakobera in https://github.com/kyleconroy/sqlc/pull/1687
    • Added documentation for type overriding and field renaming for the version 2 of the configuration file by @eullerpereira94 in https://github.com/kyleconroy/sqlc/pull/1695
    • build(deps): bump github.com/spf13/cobra from 1.4.0 to 1.5.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1694
    • Fixed typo by @i6u in https://github.com/kyleconroy/sqlc/pull/1700
    • feat(sqlite): Promote SQLite support to beta by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1699
    • feat: Codegen plugins, powered by WASM by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1684
    • feat: Set user-agent for plugin downloads by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1707
    • plugins(wasm): Change default cache location by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1709
    • plugins(wasm): Change the SHA-256 config key by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1710
    • improve mysql container support for testing by @hakobera in https://github.com/kyleconroy/sqlc/pull/1711
    • build(deps): bump github.com/pganalyze/pg_query_go/v2 from 2.1.0 to 2.1.2 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1715
    • build(deps): bump github.com/bytecodealliance/wasmtime-go from 0.37.0 to 0.38.1 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1719
    • Feat/nullable enums by @sbres in https://github.com/kyleconroy/sqlc/pull/1485
    • Support sqlite stdlib functions by @hakobera in https://github.com/kyleconroy/sqlc/pull/1712
    • fix(postgresql): Add quotes for CamelCase columns by @akutschera in https://github.com/kyleconroy/sqlc/pull/1729
    • chore: Add tests for quoting columns by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1733
    • fix: cannot parse SQLite upsert statement by @hakobera in https://github.com/kyleconroy/sqlc/pull/1732
    • sqlite - use []byte for blobs by @javiercbk in https://github.com/kyleconroy/sqlc/pull/1693
    • fix(sqlite): Regenerate test output for builtins by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1735
    • fix(wasm): Version modules by wasmtime version by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1734
    • fix: missing imports for slices by @jlisthood in https://github.com/kyleconroy/sqlc/pull/1637
    • test: Add tests for fixing slice imports by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1736
    • test: Add test cases for returning by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1737
    • feat(sqlite) add support for returning by @hakobera in https://github.com/kyleconroy/sqlc/pull/1741
    • build(deps): bump golang from 1.18.3 to 1.18.4 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1743
    • Upgrade pingcap parser (#1759) by @akutschera in https://github.com/kyleconroy/sqlc/pull/1760
    • chore: Remove catalog tests by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1762
    • build(deps): bump google.golang.org/protobuf from 1.28.0 to 1.28.1 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1763
    • Fix typo in docs/reference/config.md by @Dexter2389 in https://github.com/kyleconroy/sqlc/pull/1764
    • Add nowasm tag, fix nowasm inconsistency by @SN9NV in https://github.com/kyleconroy/sqlc/pull/1772
    • fix: missing slice import for querier by @jlisthood in https://github.com/kyleconroy/sqlc/pull/1773
    • build(deps): bump golang from 1.18.4 to 1.19.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1768
    • feat(sqlite) add support subquery and table function by @hakobera in https://github.com/kyleconroy/sqlc/pull/1771
    • docs: Update transactions how to example by @jasonblanchard in https://github.com/kyleconroy/sqlc/pull/1775
    • build: Upgrade to Go 1.19 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1780
    • build: Upgrade to go-wasmtime 0.39.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1781
    • cmd(sqlc): Bump version to v1.15.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1782
    • docs: Add 1.15 changelog by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1783

    New Contributors

    • @hakobera made their first contribution in https://github.com/kyleconroy/sqlc/pull/1687
    • @i6u made their first contribution in https://github.com/kyleconroy/sqlc/pull/1700
    • @sbres made their first contribution in https://github.com/kyleconroy/sqlc/pull/1485
    • @akutschera made their first contribution in https://github.com/kyleconroy/sqlc/pull/1729
    • @javiercbk made their first contribution in https://github.com/kyleconroy/sqlc/pull/1693
    • @Dexter2389 made their first contribution in https://github.com/kyleconroy/sqlc/pull/1764
    • @SN9NV made their first contribution in https://github.com/kyleconroy/sqlc/pull/1772
    • @jasonblanchard made their first contribution in https://github.com/kyleconroy/sqlc/pull/1775

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.14.0...v1.15.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.15.0_darwin_amd64.tar.gz(15.07 MB)
    sqlc_1.15.0_darwin_amd64.zip(14.96 MB)
    sqlc_1.15.0_linux_amd64.tar.gz(13.59 MB)
    sqlc_1.15.0_linux_amd64.zip(13.48 MB)
    sqlc_1.15.0_windows_amd64.tar.gz(11.76 MB)
    sqlc_1.15.0_windows_amd64.zip(11.68 MB)
  • v1.14.0(Jun 10, 2022)

    What's Changed

    • fix(bundler): Only close multipart writer once by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1528
    • Adding LastInsertId for Go by @Xeoncross in https://github.com/kyleconroy/sqlc/pull/1484
    • build(deps): bump github.com/lib/pq from 1.10.4 to 1.10.5 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1534
    • build(deps): bump actions/setup-java from 2 to 3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1542
    • build(deps): bump actions/setup-go from 2 to 3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1543
    • build(deps): bump golang from 1.18.0 to 1.18.1 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1547
    • Added update query to postgresql docs by @airscholar in https://github.com/kyleconroy/sqlc/pull/1535
    • feat: run sqlc with docker on windows cmd by @ParvinEyvazov in https://github.com/kyleconroy/sqlc/pull/1557
    • Pydantic models config field by @danicc097 in https://github.com/kyleconroy/sqlc/pull/1538
    • build(deps): bump github.com/jackc/pgx/v4 from 4.15.0 to 4.16.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1562
    • Prepend an underscore to a StructName if it starts with a digit. by @avalonbits in https://github.com/kyleconroy/sqlc/pull/1554
    • fix typo in feature request bug template by @josharian in https://github.com/kyleconroy/sqlc/pull/1568
    • feat: Add JSON "codegen" output by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1565
    • build(deps): bump github.com/google/go-cmp from 0.5.7 to 0.5.8 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1573
    • UPDATED: sqlc.narg() - allow user-specified nullability by @skabbes in https://github.com/kyleconroy/sqlc/pull/1536
    • docs: add documentation for sqlc.narg() by @skabbes in https://github.com/kyleconroy/sqlc/pull/1580
    • docs: Add some more example code for running transactions by @Jille in https://github.com/kyleconroy/sqlc/pull/1583
    • build(deps): bump github.com/jackc/pgx/v4 from 4.16.0 to 4.16.1 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1597
    • Add 1.13.0 to Issue Template by @danielbprice in https://github.com/kyleconroy/sqlc/pull/1592
    • Add support for CHANGE COLUMN in MySQL by @dansimau in https://github.com/kyleconroy/sqlc/pull/1605
    • build(deps): bump golang from 1.18.1 to 1.18.2 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1609
    • docs: fix examples by @orisano in https://github.com/kyleconroy/sqlc/pull/1608
    • Fix panic when calling cmd.Do subsequently by @jlisthood in https://github.com/kyleconroy/sqlc/pull/1614
    • build(deps): bump github.com/lib/pq from 1.10.5 to 1.10.6 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1627
    • doc: typo fix in overrides config example by @reddec in https://github.com/kyleconroy/sqlc/pull/1619
    • [FIX] copyfrom imports by @positiveblue in https://github.com/kyleconroy/sqlc/pull/1626
    • internal/codegen: add Enum.Valid and AllEnumValues by @josharian in https://github.com/kyleconroy/sqlc/pull/1613
    • Refactor to Package Catalog to Improve Readability by @jakoguta in https://github.com/kyleconroy/sqlc/pull/1595
    • Validate sqlc function arguments by @ryan-berger in https://github.com/kyleconroy/sqlc/pull/1633
    • Bug fix to index relation creation bug by @jakoguta in https://github.com/kyleconroy/sqlc/pull/1640
    • docs: Add documentation for version 2 of the configuration file by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1657
    • build(deps): bump golang from 1.18.2 to 1.18.3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1658
    • docs: Re-org the config page. Add JSON docs by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1659
    • build(deps): bump actions/setup-python from 3 to 4 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1666
    • add support for custom Go struct tags by @josharian in https://github.com/kyleconroy/sqlc/pull/1569
    • fix: fixed typo sql.narg in doc by @akhilmhdh in https://github.com/kyleconroy/sqlc/pull/1668
    • feat: Process-based codegen plugins by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1578
    • cmd/sqlc: Bump version to v1.14.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1670

    New Contributors

    • @Xeoncross made their first contribution in https://github.com/kyleconroy/sqlc/pull/1484
    • @airscholar made their first contribution in https://github.com/kyleconroy/sqlc/pull/1535
    • @ParvinEyvazov made their first contribution in https://github.com/kyleconroy/sqlc/pull/1557
    • @danicc097 made their first contribution in https://github.com/kyleconroy/sqlc/pull/1538
    • @avalonbits made their first contribution in https://github.com/kyleconroy/sqlc/pull/1554
    • @josharian made their first contribution in https://github.com/kyleconroy/sqlc/pull/1568
    • @skabbes made their first contribution in https://github.com/kyleconroy/sqlc/pull/1536
    • @danielbprice made their first contribution in https://github.com/kyleconroy/sqlc/pull/1592
    • @jlisthood made their first contribution in https://github.com/kyleconroy/sqlc/pull/1614
    • @reddec made their first contribution in https://github.com/kyleconroy/sqlc/pull/1619
    • @positiveblue made their first contribution in https://github.com/kyleconroy/sqlc/pull/1626
    • @jakoguta made their first contribution in https://github.com/kyleconroy/sqlc/pull/1595
    • @ryan-berger made their first contribution in https://github.com/kyleconroy/sqlc/pull/1633
    • @akhilmhdh made their first contribution in https://github.com/kyleconroy/sqlc/pull/1668

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.13.0...v1.14.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.14.0_darwin_amd64.tar.gz(8.50 MB)
    sqlc_1.14.0_darwin_amd64.zip(8.44 MB)
    sqlc_1.14.0_linux_amd64.tar.gz(7.81 MB)
    sqlc_1.14.0_linux_amd64.zip(7.75 MB)
    sqlc_1.14.0_windows_amd64.tar.gz(6.86 MB)
    sqlc_1.14.0_windows_amd64.zip(6.79 MB)
  • v1.13.0(Apr 3, 2022)

    What's Changed

    • Define code generation interface via Protocol Buffers by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1406
    • Refactor Kotlin codegen package to use plugin types by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1416
    • fix(postgresql): Remove extra newline with db argument by @rliebz in https://github.com/kyleconroy/sqlc/pull/1417
    • build(deps): bump github.com/jackc/pgx/v4 from 4.14.1 to 4.15.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1421
    • docs: Specify which db_type should be used in overrides by @egtann in https://github.com/kyleconroy/sqlc/pull/1427
    • fix copyfrom methods on interface not matching generated methods by @alexdulin in https://github.com/kyleconroy/sqlc/pull/1424
    • build(deps): bump golang from 1.17.6 to 1.17.7 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1431
    • docs: Add more documentation for go_type by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1432
    • Start filling out SQLite support by @PadraigK in https://github.com/kyleconroy/sqlc/pull/1410
    • Support codespace development by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1434
    • chore: fix extra newline in comments for copyfrom by @alexdulin in https://github.com/kyleconroy/sqlc/pull/1438
    • feat(pgx): Add support for batch operations by @jrperritt in https://github.com/kyleconroy/sqlc/pull/1437
    • SQLite: Adds a few more tests, fixes DROP TABLE by @PadraigK in https://github.com/kyleconroy/sqlc/pull/1443
    • Add support for delete statements by @PadraigK in https://github.com/kyleconroy/sqlc/pull/1447
    • feat(sqlite) Adds support for column aliases and function arguments by @PadraigK in https://github.com/kyleconroy/sqlc/pull/1455
    • feat(codegen): Insert comments in interfaces by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1458
    • build(deps): bump actions/setup-python from 2 to 3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1461
    • Refactor go codegen to plugin types by @stephen in https://github.com/kyleconroy/sqlc/pull/1460
    • feat(sdk): Add the plugin SDK package by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1463
    • build(deps): bump actions/checkout from 2.4.0 to 3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1464
    • refactor(cmd): Simplify codegen selection logic by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1466
    • chore: Generate marshal/unmarshal with vtprotobuf by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1467
    • Remove data_type from column proto by @stephen in https://github.com/kyleconroy/sqlc/pull/1468
    • docs: Add new logo by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1471
    • docs: Add hosted services to privacy / data guide by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1475
    • build(deps): bump golang from 1.17.7 to 1.17.8 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1476
    • docs: Add Plausible analytics by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1477
    • build(deps): bump github.com/spf13/cobra from 1.3.0 to 1.4.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1483
    • fix(compiler): Fix left join nullability with table aliases by @timstudd in https://github.com/kyleconroy/sqlc/pull/1491
    • build(endtoend): Don't run tests in testdata by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1492
    • build(deps): bump golang from 1.17.8 to 1.18.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1493
    • feat: Upload projects by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1436
    • Add a new issue template by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1497
    • docs: Add more examples to updating rows by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1499
    • config: Add basic fuzzing for config / overrides by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1500
    • build(deps): bump google.golang.org/protobuf from 1.27.1 to 1.28.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1504
    • Added postgres CALL support by @terrycain in https://github.com/kyleconroy/sqlc/pull/1495
    • Add version number to Python code comments by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1511
    • feat: Add sqlc version to generated Kotlin code by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1512
    • feat: Add sqlc version to generated Go code by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1513
    • feat: Pass sqlc version in codegen request by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1514
    • add materialized view support by @ludusrusso in https://github.com/kyleconroy/sqlc/pull/1509
    • fix: Regenerate testdata for CREATE TABLE AS by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1516
    • feat(python): Graduate Python support to beta by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1520
    • docs: Include scope in changelog format by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1521
    • release(cmd/sqlc): Bump to v1.13.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1523

    New Contributors

    • @rliebz made their first contribution in https://github.com/kyleconroy/sqlc/pull/1417
    • @alexdulin made their first contribution in https://github.com/kyleconroy/sqlc/pull/1424
    • @jrperritt made their first contribution in https://github.com/kyleconroy/sqlc/pull/1437
    • @stephen made their first contribution in https://github.com/kyleconroy/sqlc/pull/1460
    • @terrycain made their first contribution in https://github.com/kyleconroy/sqlc/pull/1495
    • @ludusrusso made their first contribution in https://github.com/kyleconroy/sqlc/pull/1509

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.12.0...v1.13.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.13.0_darwin_amd64.tar.gz(8.19 MB)
    sqlc_1.13.0_darwin_amd64.zip(8.14 MB)
    sqlc_1.13.0_linux_amd64.tar.gz(7.47 MB)
    sqlc_1.13.0_linux_amd64.zip(7.40 MB)
    sqlc_1.13.0_windows_amd64.tar.gz(6.56 MB)
    sqlc_1.13.0_windows_amd64.zip(6.50 MB)
  • v1.12.0(Feb 6, 2022)

    What's Changed

    • fix(sqlite): Update ANTLR v4 go.mod entry by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1336
    • fix(compiler): Check delete statements for CTEs by @wabain in https://github.com/kyleconroy/sqlc/pull/1329
    • First pass at AST-based codegen by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1333
    • Postgres Inherits by @timwmillard in https://github.com/kyleconroy/sqlc/pull/1339
    • chore(python): Add tests for :exec{result,rows} by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1344
    • Generate queries class by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1338
    • chore(python): Delete template-based codegen by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1345
    • fix(compiler): Fix validation of GROUP BY on field aliases by @timstudd in https://github.com/kyleconroy/sqlc/pull/1348
    • handling of dollar signs in function names by @Nlossae in https://github.com/kyleconroy/sqlc/pull/1359
    • Add support for CREATE TABLE a ( LIKE b ) for Postgres by @Jille in https://github.com/kyleconroy/sqlc/pull/1355
    • Update error message by @Threpio in https://github.com/kyleconroy/sqlc/pull/1366
    • feat(postgres): Add support for sql.NullInt16 by @egtann in https://github.com/kyleconroy/sqlc/pull/1376
    • Implement support for pgx's CopyFrom by @Jille in https://github.com/kyleconroy/sqlc/pull/1352
    • Fixed typo in select.md by @Hirochon in https://github.com/kyleconroy/sqlc/pull/1378
    • fix(copyfrom): Fix imports when non-copyfrom queries needed imports that copyfrom queries didn't by @Jille in https://github.com/kyleconroy/sqlc/pull/1386
    • build: Format all Go code by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1387
    • fix(postgresql): Remove extra comment newline by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1395
    • Migrate SQLite Grammar to maintained version by @PadraigK in https://github.com/kyleconroy/sqlc/pull/1397
    • Fix return type for subqueries in MySQL (#1383) by @dansimau in https://github.com/kyleconroy/sqlc/pull/1404
    • fix: Enable strict function checking by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1405
    • Bug: ALTER TABLE SET SCHEMA by @timwmillard in https://github.com/kyleconroy/sqlc/pull/1409
    • cmd/sqlc: Bump version to v1.12.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1415

    New Contributors

    • @Nlossae made their first contribution in https://github.com/kyleconroy/sqlc/pull/1359
    • @Jille made their first contribution in https://github.com/kyleconroy/sqlc/pull/1355
    • @Threpio made their first contribution in https://github.com/kyleconroy/sqlc/pull/1366
    • @egtann made their first contribution in https://github.com/kyleconroy/sqlc/pull/1376
    • @Hirochon made their first contribution in https://github.com/kyleconroy/sqlc/pull/1378
    • @PadraigK made their first contribution in https://github.com/kyleconroy/sqlc/pull/1397
    • @dansimau made their first contribution in https://github.com/kyleconroy/sqlc/pull/1404

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.11.0...v1.12.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.12.0_darwin_amd64.tar.gz(7.60 MB)
    sqlc_1.12.0_darwin_amd64.zip(7.55 MB)
    sqlc_1.12.0_linux_amd64.tar.gz(6.93 MB)
    sqlc_1.12.0_linux_amd64.zip(6.87 MB)
    sqlc_1.12.0_windows_amd64.tar.gz(6.01 MB)
    sqlc_1.12.0_windows_amd64.zip(5.96 MB)
  • v1.11.0(Nov 24, 2021)

    Bug Fixes

    • Update incorrect signatures (#1180)
    • Correct aggregate func sig (#1182)
    • Jsonb_build_object (#1211)
    • Case-insensitive identifiers (#1216)
    • Incorrect handling of meta (#1228)
    • Detect invalid INSERT expression (#1231)
    • Respect alias name for coalesce (#1232)
    • Mark nullable when casting NULL (#1233)
    • Support nullable fields in joins for MySQL engine (#1249)
    • Fix between expression handling of table references (#1268)
    • Support nullable fields in joins on same table (#1270)
    • Fix missing binds in ORDER BY (#1273)
    • Set RV for TargetList items on updates (#1252)
    • Fix MySQL parser for query without trailing semicolon (#1282)
    • Validate table alias references (#1283)
    • Add support for MySQL ON DUPLICATE KEY UPDATE (#1286)
    • Support references to columns in joined tables in UPDATE statements (#1289)
    • Add validation for GROUP BY clause column references (#1285)
    • Prevent variable redeclaration in single param conflict (#1298)
    • Use common params struct field for same named params (#1296)

    Documentation

    • Replace deprecated go get with go install (#1181)
    • Fix package name referenced in tutorial (#1202)
    • Add environment variables (#1264)
    • Add go.17+ install instructions (#1280)
    • Warn about golang-migrate file order (#1302)

    Features

    • Instrument compiler via runtime/trace (#1258)
    • Add MySQL support for BETWEEN arguments (#1265)

    Refactor

    • Move from io/ioutil to io and os package (#1164)

    Styling

    • Apply gofmt to sample code (#1261)

    New Contributors

    • @Juneezee made their first contribution in https://github.com/kyleconroy/sqlc/pull/1164
    • @ovadbar made their first contribution in https://github.com/kyleconroy/sqlc/pull/1072
    • @l4u made their first contribution in https://github.com/kyleconroy/sqlc/pull/1199
    • @oliverpool made their first contribution in https://github.com/kyleconroy/sqlc/pull/1204
    • @cqsd made their first contribution in https://github.com/kyleconroy/sqlc/pull/1209
    • @snakeclown made their first contribution in https://github.com/kyleconroy/sqlc/pull/1248
    • @timstudd made their first contribution in https://github.com/kyleconroy/sqlc/pull/1249
    • @orisano made their first contribution in https://github.com/kyleconroy/sqlc/pull/1261
    • @andreasgan made their first contribution in https://github.com/kyleconroy/sqlc/pull/1252
    • @lopezator made their first contribution in https://github.com/kyleconroy/sqlc/pull/1280
    • @danielmmetz made their first contribution in https://github.com/kyleconroy/sqlc/pull/1279
    • @wabain made their first contribution in https://github.com/kyleconroy/sqlc/pull/1301
    • @remLse made their first contribution in https://github.com/kyleconroy/sqlc/pull/1302

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.10.0...v1.11.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.11.0_darwin_amd64.tar.gz(7.38 MB)
    sqlc_1.11.0_darwin_amd64.zip(7.32 MB)
    sqlc_1.11.0_linux_amd64.tar.gz(6.74 MB)
    sqlc_1.11.0_linux_amd64.zip(6.69 MB)
    sqlc_1.11.0_windows_amd64.tar.gz(5.39 MB)
    sqlc_1.11.0_windows_amd64.zip(5.35 MB)
  • v1.10.0(Sep 7, 2021)

    Release notes coming soon!

    What's Changed

    • Fix typos in howto/select generated code sample by @naisuuuu in https://github.com/kyleconroy/sqlc/pull/1125
    • Remove MYSQL_USER and MYSQL_PASSWORD from docker-compose.yaml by @robsonpeixoto in https://github.com/kyleconroy/sqlc/pull/1123
    • build(deps): bump golang from 1.16.7 to 1.17.0 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1129
    • ci: Upgrade Go to 1.17 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1130
    • getting-started.md: fix typo by @LLLeon in https://github.com/kyleconroy/sqlc/pull/1133
    • Add RStudio to list of sponsors by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1131
    • endtoend: Run go test in CI by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1134
    • golang: Output NullUUID when necessary by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1137
    • codegen/golang: Consolidate import logic by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1139
    • codgen/golang: Use p[gq]type for network address types by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1142
    • When using pgx, map numeric types to pgtype.Numeric by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1143
    • Handle null PostgreSQL JSON values by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1145
    • codegen/golang: Add pgx support for range types by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1146
    • First attempt at a template for bugs by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1151
    • Re-order form, add configuration file section by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1153
    • codegen/golang: Use pgtype for hstore when using pgx by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1156
    • build(deps): bump github.com/lib/pq from 1.10.2 to 1.10.3 by @dependabot in https://github.com/kyleconroy/sqlc/pull/1160
    • docs: Fix invalid language support table by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1161
    • engine/mysql: Add support for LIKE by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1162
    • docs: Add a getting started guide for MySQL by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1163
    • cmd/sqlc: Bump version to v1.10.0 by @kyleconroy in https://github.com/kyleconroy/sqlc/pull/1165

    New Contributors

    • @naisuuuu made their first contribution in https://github.com/kyleconroy/sqlc/pull/1125
    • @robsonpeixoto made their first contribution in https://github.com/kyleconroy/sqlc/pull/1123
    • @LLLeon made their first contribution in https://github.com/kyleconroy/sqlc/pull/1133

    Full Changelog: https://github.com/kyleconroy/sqlc/compare/v1.9.0...v1.10.0

    Source code(tar.gz)
    Source code(zip)
    sqlc_1.10.0_darwin_amd64.tar.gz(7.24 MB)
    sqlc_1.10.0_darwin_amd64.zip(7.19 MB)
    sqlc_1.10.0_linux_amd64.tar.gz(6.63 MB)
    sqlc_1.10.0_linux_amd64.zip(6.57 MB)
    sqlc_1.10.0_windows_amd64.tar.gz(5.28 MB)
    sqlc_1.10.0_windows_amd64.zip(5.23 MB)
  • v1.9.0(Aug 13, 2021)

  • v1.8.0(May 3, 2021)

    Core

    • cmd: Fix sqlc init (#959)

    MySQL

    • Generate correct code for booleans
    • Calling mysql LAST_INSERT_ID(expr) function (#977)

    PostgreSQL

    • Support PostgreSQL 12 and 13 features by upgrading to pg_query_go/v2 (#949)
    • Fix ALTER TYPE to update column types (#973)

    Python

    • Add experimental Python support behind the --experimental flag
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.8.0-darwin-amd64.tar.gz(7.02 MB)
    sqlc-v1.8.0-darwin-amd64.zip(6.96 MB)
    sqlc-v1.8.0-linux-amd64.tar.gz(6.42 MB)
    sqlc-v1.8.0-linux-amd64.zip(6.35 MB)
    sqlc-v1.8.0-windows-amd64.tar.gz(5.07 MB)
    sqlc-v1.8.0-windows-amd64.zip(5.02 MB)
  • v1.7.0(Mar 1, 2021)

    Changelog

    Core

    • Initial Windows Support (#886)
    • UNION support (#896)
    • Publish documentation at https://docs.sqlc.dev
    • cmd: Allow config file location to be specified (#863)
    • Exit with non-zero error code when parsing fails (#870)

    MySQL

    • Compile tinyint(1) to bool (#873)
    • Support joins in update statements (#883)
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.7.0-darwin-amd64.tar.gz(11.35 MB)
    sqlc-v1.7.0-darwin-amd64.zip(11.31 MB)
    sqlc-v1.7.0-linux-amd64.tar.gz(10.18 MB)
    sqlc-v1.7.0-linux-amd64.zip(10.13 MB)
    sqlc-v1.7.0-windows-amd64.tar.gz(8.47 MB)
    sqlc-v1.7.0-windows-amd64.zip(8.44 MB)
  • v1.6.0(Nov 23, 2020)

    Notes

    The new MySQL engine, code-named Dolphin, is now default. The old engine has been removed. Your generated code will be different, but should be easy to adapt. Please open an issue if your code is now broken. If you were using the mysql:beta engine, you'll need to change that to mysql.

    Changelog

    Core

    • Add option to return emit db tags for struct fields (#656)
    • Add support for variadic stored procedures and functions (#798)
    • Fix issue installing sqlc via go get (#744)
    • Add support for nontrivial import paths for overrides (#785)

    Go

    • You can now specify the go_type import path of an override using an object instead of a string.
    overrides:
      - db_type: "uuid"
        go_type:
          import: "gopkg.in/guregu/null.v3"
          package: "null"
          type: "Bool"
    

    MySQL

    • Add function definitions for all built-in MySQL functions (#796)
    • Upgrade to the latest version of pingcap/parser (#744)
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.6.0-darwin-amd64.tar.gz(12.69 MB)
    sqlc-v1.6.0-darwin-amd64.zip(12.49 MB)
    sqlc-v1.6.0-linux-amd64.tar.gz(10.93 MB)
    sqlc-v1.6.0-linux-amd64.zip(10.83 MB)
  • v1.5.0(Aug 5, 2020)

    Notes

    The new MySQL engine, code-named Dolphin, has finally landed. To try it out, use mysql:beta for the engine value in sqlc.json. This uses the same compiler infrastructure as the PostgreSQL engine, giving it feature parity and making it easier to maintain.

    The old engine is official deprecated and will be placed behind the mysql:deprecated name in v1.6.0. The engine will be completely removed in v1.7.0. For more information, see the MySQL roadmap.

    On the PostgreSQL side of things, I've used some magic to generate function signatures for all built-in functions. This also includes many of the most popular PostgreSQL extensions. You will need to make sure to have CREATE EXTENSION ... in your schema to get this functionality.

    Changelog

    Core

    • Add option to return empty slices (instead of nil slices) in :many queries
    • Use "nullable" instead of "null" in configuration file (#571)
    • Add debugging support via SQLCDEBUG (#573)
    • Support calling functions with defaults (#635)

    PostgreSQL

    • Add support for the money type (#552)
    • Add support for 'cidr' and 'interval' types (#601)
    • Generate all functions in pg_catalog (#550)

    MySQL

    • Add the mysql:beta engine, which will be the default next release
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.5.0-darwin-amd64.tar.gz(15.16 MB)
    sqlc-v1.5.0-darwin-amd64.zip(15.24 MB)
    sqlc-v1.5.0-linux-amd64.tar.gz(13.28 MB)
    sqlc-v1.5.0-linux-amd64.zip(13.35 MB)
  • v1.4.0(Jun 17, 2020)

    Notes

    This release includes a complete refactor of the compiler internals. The compiler now uses a database-agnostic SQL AST. The PostgreSQL backend uses this new code path by default. I've tested the new path extensively, but you still may run into bugs. If you do, you can use the old code path by setting the the following environment variable: SQLC_EXPERIMENTAL_PARSER=off. The old code path will be removed in v1.5.0, so please report any bugs you run into.

    A new :execresult query command has been added. The generated methods will return (sql.Result, error), the same as DB.ExecContext.

    Changelog

    Core

    • Post the compiler to the new, database-agnostic SQL AST
    • Add support for dbmate migrations (#511)
    • Apply rename rules to enum constants (#523)
    • Add the :execresult query annotation (#542)

    PostgreSQL

    • Support columns from subselect statements (#489)
    • Temporary fix for typecast function parameters (#530)
    • Support functions with table parameters (#541)
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.4.0-darwin-amd64.tar.gz(15.53 MB)
    sqlc-v1.4.0-darwin-amd64.zip(15.47 MB)
    sqlc-v1.4.0-linux-amd64.tar.gz(13.61 MB)
  • v1.3.0(May 12, 2020)

    Core

    • Exclude golang-migrate .down.sql files in dirs + single files (https://github.com/kyleconroy/sqlc/pull/445)
    • Add EmitExactTableNames config option (https://github.com/kyleconroy/sqlc/pull/474)

    PostgreSQL

    • Add PostgreSQL support for TRUNCATE (https://github.com/kyleconroy/sqlc/pull/448)
    • Emit json.RawMessage for JSON columns (https://github.com/kyleconroy/sqlc/pull/461)
    • Fix panic walking CreateTableAsStmt (https://github.com/kyleconroy/sqlc/475)
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.3.0-darwin-amd64.tar.gz(7.49 MB)
    sqlc-v1.3.0-darwin-amd64.zip(7.46 MB)
    sqlc-v1.3.0-linux-amd64.tar.gz(6.76 MB)
  • v1.2.0(Apr 7, 2020)

    Core

    • Publish an official Docker container (https://github.com/kyleconroy/sqlc/pull/422)
    • Configuration values for schema and queries can now be a list of paths (https://github.com/kyleconroy/sqlc/pull/426)
    • Rename rules correctly apply to table names (https://github.com/kyleconroy/sqlc/pull/435)

    SQLite

    • Add support for ALTER TABLE DDL (https://github.com/kyleconroy/sqlc/pull/414)

    PostgreSQL

    • Generate correct type for SELECT EXISTS (https://github.com/kyleconroy/sqlc/pull/411)
    • Add support for ALTER TYPE RENAME / ADD VALUE (https://github.com/kyleconroy/sqlc/pull/433)
    • Properly quote reserved keywords when expanding SELECT * (https://github.com/kyleconroy/sqlc/pull/436)
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.2.0-darwin-amd64.tar.gz(7.46 MB)
    sqlc-v1.2.0-darwin-amd64.zip(7.43 MB)
    sqlc-v1.2.0-linux-amd64.tar.gz(6.76 MB)
  • v1.1.0(Mar 17, 2020)

    Core

    • Allow sqlc.arg('argname') form for named params (https://github.com/kyleconroy/sqlc/pull/351)
    • Apply changes to the ValuesList slice (#372)

    PostgreSQL

    • Add support for create-if-not-exists for 'create schema' (https://github.com/kyleconroy/sqlc/pull/362)
    • Add support for the ltree extension (#385)

    Go

    • Support Postgres macaddr type in Go (https://github.com/kyleconroy/sqlc/pull/358)
    • Scan enums when using pgx (#386)
    • Fix column comment (#392

    Kotlin

    • Add Query class to support timeout and cancellation (#368)
    Source code(tar.gz)
    Source code(zip)
    sqlc-v1.1.0-darwin-amd64.tar.gz(7.46 MB)
    sqlc-v1.1.0-darwin-amd64.zip(7.42 MB)
    sqlc-v1.1.0-linux-amd64.tar.gz(6.75 MB)
  • v1.0.0(Feb 18, 2020)

Owner
Kyle Conroy
Kyle Conroy
Type safe SQL query builder and struct mapper for Go

sq (Structured Query) ?? ?? sq is a code-generated, type safe query builder and struct mapper for Go. ?? ?? Documentation • Reference • Examples This

null 185 Dec 19, 2022
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server

About xo xo is a command-line tool to generate Go code based on a database schema or a custom query. xo works by using database metadata and SQL intro

XO 3.3k Jan 8, 2023
Go fearless SQL. Sqlvet performs static analysis on raw SQL queries in your Go code base.

Sqlvet Sqlvet performs static analysis on raw SQL queries in your Go code base to surface potential runtime errors at build time. Feature highlights:

QP Hou 460 Dec 19, 2022
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊

askgit askgit is a command-line tool for running SQL queries on git repositories. It's meant for ad-hoc querying of git repositories on disk through a

Augmentable 3.2k Jan 5, 2023
A Golang library for using SQL.

dotsql A Golang library for using SQL. It is not an ORM, it is not a query builder. Dotsql is a library that helps you keep sql files in one place and

Gustavo Chaín 653 Dec 27, 2022
a golang library for sql builder

Gendry gendry is a Go library that helps you operate database. Based on go-sql-driver/mysql, it provides a series of simple but useful tools to prepar

DiDi 1.4k Dec 26, 2022
Database Abstraction Layer (dbal) for Go. Support SQL builder and get result easily (now only support mysql)

godbal Database Abstraction Layer (dbal) for go (now only support mysql) Motivation I wanted a DBAL that No ORM、No Reflect、Concurrency Save, support S

徐佳军 56 Nov 17, 2022
SQL builder and query library for golang

__ _ ___ __ _ _ _ / _` |/ _ \ / _` | | | | | (_| | (_) | (_| | |_| | \__, |\___/ \__, |\__,_| |___/ |_| goqu is an expressive SQL bu

Doug Martin 1.8k Dec 30, 2022
SQL query builder for Go

GoSQL Query builder with some handy utility functions. Documentation For full documentation see the pkg.go.dev or GitBook. Examples // Open database a

Travis Harmon 27 Dec 12, 2022
A Go (golang) package that enhances the standard database/sql package by providing powerful data retrieval methods as well as DB-agnostic query building capabilities.

ozzo-dbx Summary Description Requirements Installation Supported Databases Getting Started Connecting to Database Executing Queries Binding Parameters

Ozzo Framework 589 Dec 31, 2022
Write your SQL queries in raw files with all benefits of modern IDEs, use them in an easy way inside your application with all the profit of compile time constants

About qry is a general purpose library for storing your raw database queries in .sql files with all benefits of modern IDEs, instead of strings and co

Sergey Treinis 26 Dec 25, 2022
Fast SQL query builder for Go

sqlf A fast SQL query builder for Go. sqlf statement builder provides a way to: Combine SQL statements from fragments of raw SQL and arguments that ma

Vlad Glushchuk 92 Dec 23, 2022
💥 A lightweight DSL & ORM which helps you to write SQL in Go.

sqlingo is a SQL DSL (a.k.a. SQL Builder or ORM) library in Go. It generates code from the database and lets you write SQL queries in an elegant way.

Qishuai Liu 274 Jan 2, 2023
Fluent SQL generation for golang

sqrl - fat-free version of squirrel - fluent SQL generator for Go Non thread safe fork of squirrel. The same handy fluffy helper, but with extra lette

Ivan Kirichenko 245 Dec 16, 2022
Fluent SQL generation for golang

Squirrel is "complete". Bug fixes will still be merged (slowly). Bug reports are welcome, but I will not necessarily respond to them. If another fork

null 5.4k Jan 6, 2023
GraphJin - Build APIs in 5 minutes with GraphQL. An instant GraphQL to SQL compiler.

GraphJin - Build APIs in 5 minutes GraphJin gives you a high performance GraphQL API without you having to write any code. GraphQL is automagically co

Vikram Rangnekar 2.5k Jan 4, 2023
golang orm and sql builder

gosql gosql is a easy ORM library for Golang. Style: var userList []UserModel err := db.FetchAll(&userList, gosql.Columns("id","name"), gosql.

RushTeam 169 Dec 22, 2022
Analyzer: helps uncover bugs by reporting a diagnostic for mistakes of *sql.Rows usage.

sqlrows sqlrows is a static code analyzer which helps uncover bugs by reporting a diagnostic for mistakes of sql.Rows usage. Install You can get sqlro

GoStaticAnalysis 86 Mar 24, 2022
LBADD: An experimental, distributed SQL database

LBADD Let's build a distributed database. LBADD is an experimental distributed SQL database, written in Go. The goal of this project is to build a dat

Tom Arrell 379 Nov 29, 2022