Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmd/vet): Prepare queries against a database #2387

Merged
merged 4 commits into from
Jun 28, 2023

Conversation

kyleconroy
Copy link
Collaborator

@kyleconroy kyleconroy commented Jun 28, 2023

Running sqlc vet will now prepare your queries against a running database to check for any issues. The database is configured on a per-project basis. Right now, only PostgreSQL is supported, but I'll be adding MySQL support shortly.

Similar to the new lint rules, the database URL is a cel expression. It has access to a map of environment variables to pull in connection details from the environment.

version: "2"
sql:
  - schema: "postgresql/schema.sql"
    queries: "postgresql/query.sql"
    engine: "postgresql"
    database:
      url: "'postgresql://%s:%s@%s:%s/authors'.format([env.PG_USER, env.PG_PASSWORD, env.PG_HOST, env.PG_PORT])"
    gen:
      go:
        package: "authors"
        out: "postgresql"

@kyleconroy kyleconroy marked this pull request as ready for review June 28, 2023 20:15
@kyleconroy kyleconroy merged commit 41c1520 into main Jun 28, 2023
7 checks passed
@kyleconroy kyleconroy deleted the kyle/sqlc-vet-prepare branch June 28, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant