diff --git a/docs/_static/customize.css b/docs/_static/customize.css index 7b00fb9706..b0882f2a05 100644 --- a/docs/_static/customize.css +++ b/docs/_static/customize.css @@ -1,3 +1,17 @@ .wy-side-nav-search img { padding: 5px 60px !important; } + +#banner { + text-align: center; + background: #2980b9; + border: 1px solid rgb(52, 49, 49); + color: #F0F0F4; + padding: 10px; + margin-bottom: 1.618em; +} + +#banner > div > a { + color: #F0F0F4; + text-decoration: underline; +} \ No newline at end of file diff --git a/docs/_templates/breadcrumbs.html b/docs/_templates/breadcrumbs.html new file mode 100644 index 0000000000..e0b9fc5fa7 --- /dev/null +++ b/docs/_templates/breadcrumbs.html @@ -0,0 +1,10 @@ +{% extends "!breadcrumbs.html" %} + +{% block breadcrumbs %} +{% if show_banner %} + +{% endif %} +{{ super() }} +{% endblock %} \ No newline at end of file diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html index e6bee29d9a..c83e9b28a4 100644 --- a/docs/_templates/layout.html +++ b/docs/_templates/layout.html @@ -1,5 +1,6 @@ {% extends "!layout.html" %} + {% block extrahead %} {{ super() }} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index ef312f27f7..3ffea9beaf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,7 +10,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os +import os # import sys # sys.path.insert(0, os.path.abspath('.')) import sphinx_rtd_theme @@ -22,7 +22,7 @@ author = 'Kyle Conroy' # The full version, including alpha/beta/rc tags -release = '1.18.0' +release = '1.19.0' # -- General configuration --------------------------------------------------- @@ -61,6 +61,10 @@ 'logo_only': True, } +html_context = { + 'show_banner': 'SHOW_LAUNCH_BANNER' in os.environ, +} + def setup(app): app.add_css_file('customize.css') diff --git a/docs/guides/plugins.md b/docs/guides/plugins.md index 031f8f979f..732eac6f0e 100644 --- a/docs/guides/plugins.md +++ b/docs/guides/plugins.md @@ -1,6 +1,6 @@ # Authoring plugins -To use plugins, you must be using [Version 2](../reference/config.html) of +To use plugins, you must be using [Version 2](../reference/config.md) of the configuration file. The top-level `plugins` array defines the available plugins. diff --git a/docs/howto/ci-cd.md b/docs/howto/ci-cd.md new file mode 100644 index 0000000000..9ac2db8aa7 --- /dev/null +++ b/docs/howto/ci-cd.md @@ -0,0 +1,91 @@ +# Suggested CI/CD setup + +If your project has more than a single developer, we suggest running `sqlc` as +part of your CI/CD pipeline. The two commands you'll want to run are `diff` and `vet` + +`sqlc diff` ensures that code is up to date. New developers to a project may +forget to run `sqlc generate`. They also might edit generated code. `diff` will +catch both scenarios. + +```diff +% sqlc-dev diff +--- a/postgresql/query.sql.go ++++ b/postgresql/query.sql.go +@@ -55,7 +55,7 @@ + + const listAuthors = `-- name: ListAuthors :many + SELECT id, name, bio FROM authors +-ORDER BY name ++ORDER BY bio + ` +``` + +`sqlc vet` runs a set of lint checks against your SQL queries. These checks are +helpful in catching anti-patterns before they make it into production. Please +see the [vet](vet.md) documentation for a complete guide on adding checks to your +project. + +## General setup + +Install `sqlc` using the [suggested instructions](../overview/install). + +Create two steps in your pipelines, one for `sqlc diff`and one for `sqlc vet`. + +## GitHub Actions + +We provide the [setup-sqlc](https://github.com/marketplace/actions/setup-sqlc) +GitHub Action to install `sqlc`. The action uses the built-in +[tool-cache](https://github.com/actions/toolkit/blob/main/packages/tool-cache/README.md) +to speed up the installation process. + +The following workflow runs `sqlc diff` on every push. + +```yaml +name: sqlc +on: [push] +jobs: + diff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: sqlc-dev/setup-sqlc@v3 + with: + sqlc-version: '1.19.0' + - run: sqlc diff +``` + +We also encourage running [`sqlc vet`](vet.md). To get the most value out of +`vet`, you'll want to set up a running database. + +```yaml +name: sqlc +on: [push] +jobs: + vet: + runs-on: ubuntu-latest + services: + postgres: + image: "postgres:15" + env: + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + env: + PG_PORT: ${{ job.services.postgres.ports['5432'] }} + + steps: + - uses: actions/checkout@v3 + - uses: sqlc-dev/setup-sqlc@v3 + with: + sqlc-version: '1.19.0' + # Connect and migrate your database here. This is an example which runs + # commands from a `schema.sql` file. + - run: psql -h localhost -U postgres -p $PG_PORT -d postgres -f schema.sql + env: + PGPASSWORD: postgres + - run: sqlc vet +``` \ No newline at end of file diff --git a/docs/howto/vet.md b/docs/howto/vet.md new file mode 100644 index 0000000000..0bf4947769 --- /dev/null +++ b/docs/howto/vet.md @@ -0,0 +1,112 @@ +# Linting queries + +*Added in v1.19.0* + +`sqlc vet` runs queries through a set of lint rules. + +Rules are defined in the `sqlc` [configuration](../reference/config) 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](https://github.com/google/cel-go). + +Each expression has access to a query object, which is defined as the following +struct: + +```proto +message Config +{ + string version = 1; + string engine = 2 ; + repeated string schema = 3; + repeated string queries = 4; +} + +message Query +{ + // SQL body + string sql = 1; + // Name of the query + string name = 2; + // One of :many, :one, :exec, etc. + string cmd = 3; + // Query parameters, if any + repeated Parameter params = 4; +} + + +message Parameter +{ + int32 number = 1; +} +``` + +This struct may be expanded in the future to include more query information. +We may also add information from a running database, such as the result from +`EXPLAIN`. + +While these examples are simplistic, they give you an idea on what types of +rules you can write. + +```yaml +version: 2 +sql: + - schema: "query.sql" + queries: "query.sql" + engine: "postgresql" + gen: + go: + package: "authors" + out: "db" + rules: + - no-pg + - no-delete + - only-one-param + - no-exec +rules: + - name: no-pg + message: "invalid engine: postgresql" + rule: | + config.engine == "postgresql" + - name: no-delete + message: "don't use delete statements" + rule: | + query.sql.contains("DELETE") + - name: only-one-param + message: "too many parameters" + rule: | + query.params.size() > 1 + - name: no-exec + message: "don't use exec" + rule: | + query.cmd == "exec" +``` + +## Built-in rules + +### sqlc/db-prepare + +When a [database](../reference/config.html#database) in configured, the `sqlc/db-preapre` +rule will attempt to prepare each of your queries against the connected +database. Any failures will be reported to standard error. + +```yaml +version: 2 +sql: + - schema: "query.sql" + queries: "query.sql" + engine: "postgresql" + gen: + go: + package: "authors" + out: "db" + database: + uri: "postgresql://postgres:password@localhost:5432/postgres" + rules: + - sqlc/db-prepare +``` + +To see this in action, check out the [authors +example](https://github.com/kyleconroy/sqlc/blob/main/examples/authors/sqlc.yaml). + +Please note that `sqlc` does not manage or migrate the database. Use your +migration tool of choice to create the necessary database tables and objects. \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 7f6c7db3b8..3ad59b1e18 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -54,6 +54,8 @@ code ever again. howto/ddl.md howto/structs.md + howto/vet.md + howto/ci-cd.md howto/upload.md .. toctree:: diff --git a/docs/overview/install.md b/docs/overview/install.md index c92d6bfabc..921c0b0d53 100644 --- a/docs/overview/install.md +++ b/docs/overview/install.md @@ -48,10 +48,10 @@ docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate ## Downloads -Get pre-built binaries for *v1.18.0*: +Get pre-built binaries for *v1.19.0*: -- [Linux](https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz) -- [macOS](https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_darwin_amd64.zip) -- [Windows (MySQL only)](https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_windows_amd64.zip) +- [Linux](https://github.com/kyleconroy/sqlc/releases/download/v1.19.0/sqlc_1.19.0_linux_amd64.tar.gz) +- [macOS](https://github.com/kyleconroy/sqlc/releases/download/v1.19.0/sqlc_1.19.0_darwin_amd64.zip) +- [Windows (MySQL only)](https://github.com/kyleconroy/sqlc/releases/download/v1.19.0/sqlc_1.19.0_windows_amd64.zip) See [downloads.sqlc.dev](https://downloads.sqlc.dev/) for older versions. diff --git a/docs/reference/changelog.md b/docs/reference/changelog.md index 7d2bb2327b..5ddd9d34f8 100644 --- a/docs/reference/changelog.md +++ b/docs/reference/changelog.md @@ -1,6 +1,219 @@ # Changelog All notable changes to this project will be documented in this file. +## [1.19.0](https://github.com/kyleconroy/sqlc/releases/tag/v1.19.0) +Released 2023-07-06 + +### Release notes + +#### sqlc vet + +[`vet`](../howto/vet.md) runs queries through a set of lint rules. + +Rules are defined in the `sqlc` [configuration](config.html#rules) 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](https://github.com/google/cel-go). + +While these examples are simplistic, they give you an idea on what types of +rules you can write. + +```yaml +version: 2 +sql: + - schema: "query.sql" + queries: "query.sql" + engine: "postgresql" + gen: + go: + package: "authors" + out: "db" + rules: + - no-pg + - no-delete + - only-one-param + - no-exec +rules: + - name: no-pg + message: "invalid engine: postgresql" + rule: | + config.engine == "postgresql" + - name: no-delete + message: "don't use delete statements" + rule: | + query.sql.contains("DELETE") + - name: only-one-param + message: "too many parameters" + rule: | + query.params.size() > 1 + - name: no-exec + message: "don't use exec" + rule: | + query.cmd == "exec" +``` + +##### Database connectivity + +`vet` also marks the first time that `sqlc` can connect to a live, running +database server. This functionality will be expanded over time, but for now it +powers the `sqlc/db-prepare` built-in rule. + +When a [database](config.html#database) in configured, the `sqlc/db-preapre` +rule will attempt to prepare each of your queries against the connected +database. Any failures will be reported to standard error. + +```yaml +version: 2 +sql: + - schema: "query.sql" + queries: "query.sql" + engine: "postgresql" + gen: + go: + package: "authors" + out: "db" + database: + uri: "postgresql://postgres:password@localhost:5432/postgres" + rules: + - sqlc/db-prepare +``` + +To see this in action, check out the [authors +example](https://github.com/kyleconroy/sqlc/blob/main/examples/authors/sqlc.yaml). + +Please note that `sqlc` does not manage or migrate the database. Use your +migration tool of choice to create the necessary database tables and objects. + +#### Omit unused structs + +Added a new configuration parameter `omit_unused_structs` which, when set to +true, filters out table and enum structs that aren't used in queries for a given +package. + +#### Suggested CI/CD setup + +With the addition of `sqlc diff` and `sqlc vet`, we encourage users to run sqlc +in your CI/CD pipelines. See our [suggested CI/CD setup](../howto/ci-cd.md) for +more information. + +#### Simplified plugin development + +The [sqlc-gen-kotlin](https://github.com/sqlc-dev/sqlc-gen-kotlin) and +[sqlc-gen-python](https://github.com/sqlc-dev/sqlc-gen-python) plugins have been +updated use the upcoming [WASI](https://wasi.dev/) support in [Go +1.21](https://tip.golang.org/doc/go1.21#wasip1). Building these plugins no +longer requires [TinyGo](https://tinygo.org/). + +### Changes + +#### Bug Fixes + +- Pointers overrides skip imports in generated query files (#2240) +- CASE-ELSE clause is not properly parsed when a value is constant (#2238) +- Fix toSnakeCase to handle input in CamelCase format (#2245) +- Add location info to sqlite ast (#2298) +- Add override tags to result struct (#1867) (#1887) +- Override types of aliased columns and named parameters (#1884) +- Resolve duplicate fields generated when inheriting multiple tables (#2089) +- Check column references in ORDER BY (#1411) (#1915) +- MySQL slice shadowing database/sql import (#2332) +- Don't defer rows.Close() if pgx.BatchResults.Query() failed (#2362) +- Fix type overrides not working with sqlc.slice (#2351) +- Type overrides on columns for parameters inside an IN clause (#2352) +- Broken interaction between query_parameter_limit and pq.Array() (#2383) +- (codegen/golang) Bring :execlastid in line with the rest (#2378) + +#### Documentation + +- Update changelog.md with some minor edits (#2235) +- Add F# community plugin (#2295) +- Add a ReadTheDocs config file (#2327) +- Update query_parameter_limit documentation (#2374) +- Add launch announcement banner + +#### Features +- PostgreSQL capture correct line and column numbers for parse error (#2289) +- Add supporting COMMENT ON VIEW (#2249) +- To allow spaces between function name and arguments of functions to be rewritten (#2250) +- Add support for pgx/v5 emit_pointers_for_null_types flag (#2269) +- (mysql) Support unsigned integers (#1746) +- Allow use of table and column aliases for table functions returning unknown types (#2156) +- Support "LIMIT ?" in UPDATE and DELETE for MySQL (#2365) +- (internal/codegen/golang) Omit unused structs from output (#2369) +- Improve default names for BETWEEN ? AND ? to have prefixes from_ and to_ (#2366) +- (cmd/sqlc) Add the vet subcommand (#2344) +- (sqlite) Add support for UPDATE/DELETE with a LIMIT clause (#2384) +- Add support for BETWEEN sqlc.arg(min) AND sqlc.arg(max) (#2373) +- (cmd/vet) Prepare queries against a database (#2387) +- (cmd/vet) Prepare queries for MySQL (#2388) +- (cmd/vet) Prepare SQLite queries (#2389) +- (cmd/vet) Simplify environment variable substiution (#2393) +- (cmd/vet) Add built-in db-prepare rule +- Add compiler support for NOTIFY and LISTEN (PostgreSQL) (#2363) + +#### Miscellaneous Tasks + +- A few small staticcheck fixes (#2361) +- Remove a bunch of dead code (#2360) +- (scripts/regenerate) Should also update stderr.txt (#2379) + +#### Build + +- (deps) Bump requests from 2.25.1 to 2.31.0 in /docs (#2283) +- (deps) Bump golang from 1.20.3 to 1.20.4 (#2256) +- (deps) Bump google.golang.org/grpc from 1.54.0 to 1.55.0 (#2265) +- (deps) Bump github.com/mattn/go-sqlite3 from 1.14.16 to 1.14.17 (#2293) +- (deps) Bump golang.org/x/sync from 0.1.0 to 0.2.0 (#2266) +- (deps) Bump golang from 1.20.4 to 1.20.5 (#2301) +- Configure dependencies via devenv.sh (#2319) +- Configure dependencies via devenv.sh (#2326) +- (deps) Bump golang.org/x/sync from 0.2.0 to 0.3.0 (#2328) +- (deps) Bump google.golang.org/grpc from 1.55.0 to 1.56.0 (#2333) +- (deps) Bump google.golang.org/protobuf from 1.30.0 to 1.31.0 (#2370) +- (deps) Bump actions/checkout from 2 to 3 (#2357) +- Run govulncheck on all builds (#2372) +- (deps) Bump google.golang.org/grpc from 1.56.0 to 1.56.1 (#2358) + +#### Cmd/sqlc + +- Show helpful output on missing subcommand (#2345) + +#### Codegen + +- Use catalog's default schema (#2310) +- (go) Add tests for tables with dashes (#2312) +- (go) Strip invalid characters from table and column names (#2314) +- (go) Support JSON tags for nullable enum structs (#2121) + +#### Internal/config + +- Support golang overrides for slices (#2339) + +#### Kotlin + +- Use latest version of sqlc-gen-kotlin (#2356) + +#### Postgres + +- Column merging for table inheritence (#2315) + +#### Protos + +- Add missing field name (#2354) + +#### Python + +- Use latest version of sqlc-gen-python (#2355) + +#### Remote + +- Use user-id/password auth (#2262) + +#### Sqlite + +- Fixed sqlite column type override (#1986) + + ## [1.18.0](https://github.com/kyleconroy/sqlc/releases/tag/v1.18.0) Released 2023-04-27 diff --git a/docs/reference/cli.md b/docs/reference/cli.md index a6033f2205..427379c0f5 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -7,16 +7,19 @@ Usage: Available Commands: compile Statically check SQL for syntax and type errors completion Generate the autocompletion script for the specified shell + diff Compare the generated files to the existing files generate Generate Go code from SQL help Help about any command init Create an empty sqlc.yaml settings file upload Upload the schema, queries, and configuration for this project version Print the sqlc version number + vet Vet examines queries Flags: - -x, --experimental enable experimental features (default: false) -f, --file string specify an alternate config file (default: sqlc.yaml) -h, --help help for sqlc + --no-database disable database connections (default: false) + --no-remote disable remote execution (default: false) Use "sqlc [command] --help" for more information about a command. -``` +``` \ No newline at end of file diff --git a/docs/reference/config.md b/docs/reference/config.md index 5218af896e..21383c9371 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -15,6 +15,10 @@ sql: go: package: "authors" out: "postgresql" + database: + uri: "postgresql://postgres:postgres@localhost:5432/postgres" + rules: + - sqlc/db-prepare - schema: "mysql/schema.sql" queries: "mysql/query.sql" engine: "mysql" @@ -35,12 +39,16 @@ Each mapping in the `sql` collection has the following keys: - `queries`: - Directory of SQL queries or path to single SQL file; or a list of paths. - `codegen`: - - A colleciton of mappings to configure code generators. See [codegen](#codegen) for the supported keys. + - A collection of mappings to configure code generators. See [codegen](#codegen) for the supported keys. - `gen`: - A mapping to configure built-in code generators. See [gen](#gen) for the supported keys. +- `database`: + - A mapping configure database connections. See [database](#database) for the supported keys. +- `rules`: + - A collection of rule names to run via `sqlc vet`. See [rules](#rules) for configuration options. - `strict_function_checks` - If true, return an error if a called SQL function does not exist. Defaults to `false`. - - + ### codegen The `codegen` mapping supports the following keys: @@ -72,7 +80,32 @@ sql: emit_async_querier: true query_parameter_limit: 5 ``` - + +### database + +The `database` mapping supports the following keys: + +- `uri`: + - Database connection URL + +The URI can contain references to environment variables using the `${...}` +syntax. In the following example, the connection string will set the value of +the password to the value set in the `PG_PASSWORD` environment variable. + +```yaml +version: '2' +sql: +- schema: schema.sql + queries: query.sql + engine: postgresql + database: + uri: postgresql://postgres:${PG_PASSWORD}@localhost:5432/authors + gen: + go: + package: authors + out: postgresql +``` + ### gen The `gen` mapping supports the following keys: @@ -301,11 +334,59 @@ plugins: process: cmd: "sqlc-gen-json" ``` - + +### rules + +Each mapping in the `rules` collection has the following keys: + +- `name`: + - The name of this rule. Required +- `rule`: + - A [Common Expression Language (CEL)](https://github.com/google/cel-spec) expression. Required. +- `message`: + - An optional message shown when the rule returns true. + +See the [vet](../howto/vet.md) documentation for help writing custom rules. + +```yaml +version: 2 +sql: + - schema: "query.sql" + queries: "query.sql" + engine: "postgresql" + gen: + go: + package: "authors" + out: "db" + rules: + - no-pg + - no-delete + - only-one-param + - no-exec +rules: + - name: no-pg + message: "invalid engine: postgresql" + rule: | + config.engine == "postgresql" + - name: no-delete + message: "don't use delete statements" + rule: | + query.sql.contains("DELETE") + - name: only-one-param + message: "too many parameters" + rule: | + query.params.size() > 1 + - name: no-exec + message: "don't use exec" + rule: | + query.cmd == "exec" +``` + ### global overrides -Sometimes, the same configuration must be done across various specfications of code generation. -Then a global definition for type overriding and field renaming can be done using the `overrides` mapping the following manner: +Sometimes, the same configuration must be done across various specifications of +code generation. Then a global definition for type overriding and field +renaming can be done using the `overrides` mapping the following manner: ```yaml version: "2" @@ -338,11 +419,18 @@ sql: out: "mysql ``` -With the previous configuration, whenever a struct field is generated from a table column that is called `id`, it will generated as `Identifier`. -Also, whenever there is a nullable `timestamp with time zone` column in a Postgres table, it will be generated as `null.Time`. -Note that, the mapping for global type overrides has a field called `engine` that is absent in the regular type overrides. This field is only used when there are multiple definitions using multiple engines. Otherwise, the value of the `engine` key will be defaulted to the engine that is currently being used. +With the previous configuration, whenever a struct field is generated from a +table column that is called `id`, it will generated as `Identifier`. + +Also, whenever there is a nullable `timestamp with time zone` column in a +Postgres table, it will be generated as `null.Time`. Note that, the mapping for +global type overrides has a field called `engine` that is absent in the regular +type overrides. This field is only used when there are multiple definitions +using multiple engines. Otherwise, the value of the `engine` key will be +defaulted to the engine that is currently being used. -Currently, type overrides and field renaming, both global and regular, are only fully supported in Go. +Currently, type overrides and field renaming, both global and regular, are only +fully supported in Go. ## Version 1 diff --git a/docs/tutorials/getting-started-mysql.md b/docs/tutorials/getting-started-mysql.md index ce0e3c9758..cefce611f1 100644 --- a/docs/tutorials/getting-started-mysql.md +++ b/docs/tutorials/getting-started-mysql.md @@ -1,7 +1,7 @@ # Getting started with MySQL This tutorial assumes that the latest version of sqlc is -[installed](../overview/install.html) and ready to use. +[installed](../overview/install.md) and ready to use. Create a new directory called `sqlc-tutorial` and open it up. diff --git a/docs/tutorials/getting-started-postgresql.md b/docs/tutorials/getting-started-postgresql.md index 4326b0b6d3..bc761be004 100644 --- a/docs/tutorials/getting-started-postgresql.md +++ b/docs/tutorials/getting-started-postgresql.md @@ -1,7 +1,7 @@ # Getting started with PostgreSQL This tutorial assumes that the latest version of sqlc is -[installed](../overview/install.html) and ready to use. +[installed](../overview/install.md) and ready to use. Create a new directory called `sqlc-tutorial` and open it up. diff --git a/docs/tutorials/getting-started-sqlite.md b/docs/tutorials/getting-started-sqlite.md index 76c2dfc97e..96bb693e23 100644 --- a/docs/tutorials/getting-started-sqlite.md +++ b/docs/tutorials/getting-started-sqlite.md @@ -1,7 +1,7 @@ # Getting started with SQLite This tutorial assumes that the latest version of sqlc is -[installed](../overview/install.html) and ready to use. +[installed](../overview/install.md) and ready to use. Create a new directory called `sqlc-tutorial` and open it up. diff --git a/internal/cmd/vet.go b/internal/cmd/vet.go index 78656fe11b..33d19fec05 100644 --- a/internal/cmd/vet.go +++ b/internal/cmd/vet.go @@ -291,7 +291,7 @@ func (c *checker) checkSQL(ctx context.Context, s config.SQL) error { defer db.Close() prep = &dbPreparer{db} default: - return fmt.Errorf("unsupported database url: %s", s.Engine) + return fmt.Errorf("unsupported database uri: %s", s.Engine) } }