|
1 | 1 | # Configuration
|
2 | 2 |
|
3 |
| -The `sqlc` tool is configured via a `sqlc.yaml` or `sqlc.json` file. This file must be |
4 |
| -in the directory where the `sqlc` command is run. |
| 3 | +The `sqlc` tool is configured via a `sqlc.yaml` or `sqlc.json` file. This |
| 4 | +file must be in the directory where the `sqlc` command is run. |
5 | 5 |
|
6 | 6 | ## Version 2
|
7 | 7 |
|
@@ -34,10 +34,44 @@ Each mapping in the `sql` collection has the following keys:
|
34 | 34 | - Directory of SQL migrations or path to single SQL file; or a list of paths.
|
35 | 35 | - `queries`:
|
36 | 36 | - Directory of SQL queries or path to single SQL file; or a list of paths.
|
| 37 | +- `codegen`: |
| 38 | + - A colleciton of mappings to configure code generators. See [codegen](#codegen) for the supported keys. |
37 | 39 | - `gen`:
|
38 | 40 | - A mapping to configure built-in code generators. See [gen](#gen) for the supported keys.
|
39 | 41 | - `strict_function_checks`
|
40 | 42 | - If true, return an error if a called SQL function does not exist. Defaults to `false`.
|
| 43 | + - |
| 44 | +### codegen |
| 45 | + |
| 46 | +The `codegen` mapping supports the following keys: |
| 47 | + |
| 48 | +- `out`: |
| 49 | + - Output directory for generated code. |
| 50 | +- `plugin`: |
| 51 | + - The name of the plugin. Must be defined in the `plugins` collection. |
| 52 | +- `options`: |
| 53 | + - A mapping of plugin-specific options. |
| 54 | + |
| 55 | +```yaml |
| 56 | +version: '2' |
| 57 | +plugins: |
| 58 | +- name: py |
| 59 | + wasm: |
| 60 | + url: https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm |
| 61 | + sha256: 428476c7408fd4c032da4ec74e8a7344f4fa75e0f98a5a3302f238283b9b95f2 |
| 62 | +sql: |
| 63 | +- schema: "schema.sql" |
| 64 | + queries: "query.sql" |
| 65 | + engine: postgresql |
| 66 | + codegen: |
| 67 | + - out: src/authors |
| 68 | + plugin: py |
| 69 | + options: |
| 70 | + package: authors |
| 71 | + emit_sync_querier: true |
| 72 | + emit_async_querier: true |
| 73 | + query_parameter_limit: 5 |
| 74 | +``` |
41 | 75 |
|
42 | 76 | ### gen
|
43 | 77 |
|
@@ -223,10 +257,27 @@ Each mapping in the `plugins` collection has the following keys:
|
223 | 257 |
|
224 | 258 | - `name`:
|
225 | 259 | - The name of this plugin. Required
|
226 |
| -- `process`: |
| 260 | +- `process`: A mapping with a single `cmd` key |
227 | 261 | - `cmd`:
|
228 | 262 | - The executable to call when using this plugin
|
229 |
| - |
| 263 | +- `wasm`: A mapping with a two keys `url` and `sha256` |
| 264 | + - `url`: |
| 265 | + - The URL to fetch the WASM file. Supports the `https://` or `file://` schemes. |
| 266 | + - `sha256` |
| 267 | + - The SHA256 checksum for the downloaded file. |
| 268 | + |
| 269 | +```yaml |
| 270 | +version: 2 |
| 271 | +plugins: |
| 272 | +- name: "py" |
| 273 | + wasm: |
| 274 | + url: "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm" |
| 275 | + sha256: "428476c7408fd4c032da4ec74e8a7344f4fa75e0f98a5a3302f238283b9b95f2" |
| 276 | +- name: "js" |
| 277 | + process: |
| 278 | + cmd: "sqlc-gen-json" |
| 279 | +``` |
| 280 | + |
230 | 281 | ### global overrides
|
231 | 282 |
|
232 | 283 | Sometimes, the same configuration must be done across various specfications of code generation.
|
|
0 commit comments