Skip to content

Request for comments: SQL to Go code generator quite similar to sqlc #854

Closed
@jschaf

Description

@jschaf

Hi! I'm working on sqld, a code generator that takes SQL queries and outputs type-safe Go code using pgx. I'm a big fan of sqlc (hence the name) and if you have some time, I'd love to get your thoughts on the RFC, specifically:

  1. Is it possible or beneficial to merge the approaches used in sqlc and sqld? I created a new project because one of sqlc's value propositions is that it must work without running Postgres. For sqld, I wanted to avoid implementing parsing logic by leaning more heavily on Postgres. Additionally, I'd prefer to only support pgx instead of the sql package.

  2. Are you okay with the name sqld? I thought it was mildly clever but I'm open to changing it.

  3. Possible collaboration on a future ClientTrace API similar to the Go stdlib http tracing: https://blog.golang.org/http-tracing. There's a ton of useful metrics to surface (DNS resolution for host names, response parse time, pool queue time). I've created an initial pgx-focused ClientTrace.go that I use in the generated code.

  4. Overall API design.

  • Is it worth supporting options when building a Querier?
  • How many inline parameters before switching to a struct: FindAuthors(ctx, "name") vs FindAuthors(ctx, FindAuthorsParams{Name: "name"}). Looks like sqlc switches after 1 parameter.

RFC: sqld: Go code generation for Postgres (Google doc)

To summarize the main differences between sqld and sqlc:

  1. sqld requires a running Postgres instance to get type information by executing queries.
  2. sqld only supports pgx.

I've started a similar discussion on the pgx repo: jackc/pgx#915. Feel free to close this whenever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions