scythe-sql 0.21.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2923 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.21.0] - 2026-12-01
11
+
12
+ ### Added
13
+
14
+ - `typescript-pg` accepts `bigint = "string" | "number" | "bigint"` for
15
+ `int8` values. The default, `string`, matches node-postgres, which returns
16
+ `int8` (`COUNT(*)`, `SUM(int)`, `row_number()`, `BIGINT` columns) as a
17
+ string; `number` accepts the precision loss, and `bigint` emits a
18
+ `types.setTypeParser` helper for OIDs 20 and 1016 (issue #293).
19
+ - `typescript-pg` accepts `batch_transaction = "savepoint" | "begin" | "none"`
20
+ for `:batch`. The default, `savepoint`, joins the caller's transaction
21
+ instead of committing it (issue #297).
22
+ - The `-- @type <column> = <neutral_type>` annotation overrides an output
23
+ column's inferred type, including a column the analyzer could not type on
24
+ its own (issue #300).
25
+ - PostgreSQL full-text search, jsonpath and set/array builtins are known
26
+ functions: `to_tsvector`, `to_tsquery`, `plainto_tsquery`,
27
+ `websearch_to_tsquery`, `setweight`, `ts_rank`, `ts_rank_cd`,
28
+ `jsonb_path_query`, `jsonb_path_query_first`, `jsonb_path_exists`,
29
+ `jsonb_array_elements_text`, `string_to_array`, and `generate_series` in a
30
+ select list (issue #300).
31
+ - npm ships five platform packages (`scythe-cli-<platform>`) and PyPI ships a
32
+ platform wheel per release target, each containing the full release archive
33
+ (binary, parser helpers, manifest and notices). Installation needs no
34
+ GitHub download and no proxy; the registry's integrity hashes cover the
35
+ binaries. A download fallback remains for hosts no platform covers (musl
36
+ Linux, Windows arm64). `scythe audit --cluster-scope` now finds its parser
37
+ helpers when installed from npm or PyPI.
38
+ - A hand-maintained `typescript-pg-regressions` integration harness exercises
39
+ the runtime behaviour of the fixes below against a real database.
40
+
41
+ ### Changed
42
+
43
+ - Minimum supported versions raised: Node.js 22, PHP 8.3, Elixir 1.17, Go
44
+ 1.27, Java 25. Python 3.11 is now the minimum supported version; Python 3.10
45
+ reached end of life.
46
+ - `typescript-pg` emits types that match node-postgres at runtime: `int64` is
47
+ `string` (see `bigint`), `date` is `Date`, and `JSON`/`JSONB` is `unknown`
48
+ (it can be an object, array, or scalar; `@json` still gives a typed object)
49
+ (issues #293, #294, #301).
50
+ - Generated `typescript-pg` functions take `Pick<PoolClient, "query">` instead
51
+ of `PoolClient`, so a `Pool`, `Client`, or pooled client all work (issue
52
+ #303).
53
+ - A quoted SQL identifier keeps its literal casing in generated field names;
54
+ `SELECT "createdAt"` is keyed `createdAt`, not `created_at` (issue #296).
55
+ - Development tasks run with mise instead of go-task. `mise.toml` and
56
+ `mise.lock` pin every tool at the xberg-io/toolchains baseline, with Rust
57
+ still pinned by `rust-toolchain.toml`. Integration tasks live in
58
+ `integration_tests/mise.toml` and run from that directory.
59
+ - CI installs its tools with `setup-mise`, runs its macOS jobs on `macos-26`
60
+ and `macos-26-intel`, and pins every action to a tag.
61
+ - Governance and plugin bundles are regenerated with ai-rulez, which is no
62
+ longer pinned anywhere: tasks, the MCP server and the hook source follow its
63
+ latest release.
64
+ - `generate:scaffolding` no longer rewrites an existing dependency manifest
65
+ (`go.mod`, `package.json`, `pom.xml`, `pyproject.toml`, ...). Those are owned
66
+ by their package manager, which also owns the committed lockfile;
67
+ `--force-deps` restores the template-driven behaviour.
68
+
69
+ ### Fixed
70
+
71
+ - `<> ALL($1::text[])` registers its parameter, like `ANY` (issue #295).
72
+ - Columns of `unnest(...)` in `FROM` resolve from the array element type,
73
+ including the multi-array, `WITH ORDINALITY`, aliased-column and bare-alias
74
+ forms (issue #299).
75
+ - `@optional` rewrites type their placeholder for PostgreSQL
76
+ (`($1::text IS NULL OR …)`), instead of failing with "could not determine
77
+ data type of parameter" (issue #298).
78
+ - A JSON parameter is JSON-encoded before binding, so a JS array round-trips
79
+ through `jsonb` instead of being sent as a PostgreSQL array literal (issue
80
+ #301).
81
+ - The `:one`/`:opt` contract is documented correctly across the TypeScript,
82
+ Python, C#, Java and Kotlin pages: `:one` throws (or raises) on a missing
83
+ row, and `:opt` is the nullable variant (issue #302).
84
+ - The Snowflake row adapter no longer calls `str()` on an already-`str` key,
85
+ which a newer pyrefly flagged.
86
+ - The published crate manifests no longer repeat `license-file` alongside
87
+ `license` or `homepage` alongside `documentation`, which Cargo 1.100 warns
88
+ on.
89
+
90
+ ### Upgrade notes
91
+
92
+ - `typescript-pg` `int64` is now `string`. Set `bigint = "number"` to keep the
93
+ old type, or `bigint = "bigint"` to install a `setTypeParser` helper.
94
+ - `typescript-pg` `date` is now `Date`; `JSON`/`JSONB` is `unknown`. Use
95
+ `@json` for a typed object.
96
+ - `:batch` now uses a savepoint by default and expects the caller's
97
+ transaction. Set `batch_transaction = "begin"` for the old standalone
98
+ behaviour, or `"none"` to leave transaction control to the caller.
99
+ - A quoted column's field name keeps its literal casing, so a schema that
100
+ relied on the previous snake_case rename must alias the column in SQL or set
101
+ `field_case = "camelCase"`.
102
+
103
+ ## [0.20.2] - 2026-10-31
104
+
105
+ ### Changed
106
+
107
+ - `duckdb` and `libduckdb-sys` move from the exact `=1.10506.1` pin to the
108
+ `1.20000` caret range. The pin existed only because DuckDB 1.2's static
109
+ extension autoregister archive broke the zig cross-linker the pre-0.20.1
110
+ single-job pipeline used; every archive is built natively on its own runner
111
+ now, so the workaround is obsolete (issue #278).
112
+ - `release/duckdb-binary-sizes.json` is re-baselined for the DuckDB 1.2
113
+ binaries from native canary builds on the hosts this change could build on.
114
+ Entries that could not be observed here are marked `"measured": false` and
115
+ keep their previous figure until CI's `task release:canary` records them.
116
+ - The `python-snowflake` backend reads result rows by projected column name
117
+ through `snowflake.connector.DictCursor` instead of by position. Generated
118
+ code therefore type-checks against both snowflake-connector-python 4.x and
119
+ 5.x, whose `cursor.fetchall()` rows are typed `dict[str, Any]` (issue #281).
120
+ The python-snowflake harness lockfile moves to 5.1.0 and its minimum Python
121
+ to 3.11, as required by that connector release. The fakesnow-emulator run
122
+ pins the client to 4.x at invocation time because fakesnow 0.12.1 still
123
+ imports a module the 5.x connector removed; 5.x is covered by generated type
124
+ checking.
125
+ - Workspace dependencies upgraded, including `sqruff-lib` 0.44 and the DuckDB
126
+ 1.2 stack (`arrow` 60, `comfy-table` 8, `zip` removal). `cargo update` also
127
+ took the compatible patch releases across the workspace.
128
+
129
+ ## [0.20.1] - 2026-10-27
130
+
131
+ ### Fixed
132
+
133
+ - Releases publish archives, checksums and a GitHub release again. GoReleaser
134
+ cleaned `dist` and then rejected its own distribution directory after the
135
+ parser-helper before-hook wrote into it ("dist is not empty"), so v0.20.0
136
+ reached crates.io with no installable release (issues #271 and #277).
137
+
138
+ ### Changed
139
+
140
+ - The release pipeline no longer uses GoReleaser. Each of the five archives is
141
+ built natively on its own runner (Linux in a manylinux_2_28 container, macOS
142
+ on the native Intel and arm64 runners, Windows on MSVC) and uploaded to a
143
+ draft release that is promoted only once every archive and the checksums file
144
+ are present.
145
+ - The Windows target is `x86_64-pc-windows-msvc` instead of the mingw
146
+ cross-build `x86_64-pc-windows-gnu`. The setup action, the npm and PyPI
147
+ wrappers and the binstall metadata resolve the same platform as before.
148
+ - Workspace dependencies upgraded, including `rusqlite` 0.41, `sqruff-lib` 0.43,
149
+ `minijinja` 3 and the Arrow 60 stack. The integration test generator moved to
150
+ minijinja 3's `value::Serde` context wrapper.
151
+ - `duckdb` stays on 1.10506.1 for this release. DuckDB 1.2 links its static
152
+ extension autoregister archive in a form the cross-compiler the old pipeline
153
+ used rejects; building natively removes that blocker, but the binary-size
154
+ ratchet has not been re-measured for it, so the upgrade lands separately.
155
+
156
+ ### Added
157
+
158
+ - Publish CI verifies the published Linux archive: its checksum, the bundled
159
+ `scythe-pg15-parser`/`scythe-pg18-parser` helpers against
160
+ `pg-parser-manifest.json`, and the cluster-scope gate run from the extracted
161
+ archive for both grammar versions.
162
+ - Publish CI fails unless crates.io, the GitHub release (including its "latest"
163
+ marker), npm and PyPI all carry the release, and publishes to crates.io only
164
+ after the archives are verified, so the channels cannot drift apart the way
165
+ they did for v0.20.0 and v0.18.2.
166
+
167
+ ### Security
168
+
169
+ - Updated `rustls` to 0.23.46, `rustls-webpki` to 0.103.16, `tokio` to 1.54.1,
170
+ `ctutils` to 0.4.6 and `webpki-roots` to 1.0.11 to resolve RUSTSEC-2026-0346,
171
+ -0347, -0348, -0349, -0381, -0382, -0385 and -0386.
172
+
173
+ ## [0.20.0] - 2026-10-06
174
+
175
+ ### Added
176
+
177
+ - `scythe audit --cluster-scope` gates PostgreSQL planned-schema inputs with a
178
+ real, version-pinned grammar (`--pg-version 15|18`, default 18) instead of a
179
+ hand-written scanner. It refuses, by default, every statement not proven
180
+ database-local: role and membership, database, tablespace, subscription,
181
+ parameter-privilege, `ALTER SYSTEM`, and shared-ownership writes.
182
+ - Routine bodies (`DO`, `FUNCTION`, `PROCEDURE`) are inspected recursively,
183
+ including statically recoverable `EXECUTE`/`format(...)`; unresolved dynamic
184
+ SQL is refused rather than assumed local. Findings carry stable codes
185
+ (`SC-CLUSTER01`–`SC-CLUSTER04`) and can never be suppressed by `--severity` or
186
+ `--exit-zero`.
187
+ - The pinned PostgreSQL parser helpers (`scythe-pg15-parser`,
188
+ `scythe-pg18-parser`), their provenance manifest, and third-party license
189
+ notices ship beside the `scythe` binary in the Linux and macOS release
190
+ archives. The PG18 helper is built from a pinned libpg_query 18.1.0 patch that
191
+ fixes three upstream PL/pgSQL JSON regressions (pganalyze/libpg_query#337).
192
+
193
+ ### Changed
194
+
195
+ - Workspace versions and generated provenance headers move to 0.20.0.
196
+
197
+ ## [0.19.0] - 2026-10-04
198
+
199
+ ### Changed
200
+
201
+ - Upgraded workspace dependencies and integration fixtures across the supported language backends,
202
+ including Snowflake, Exposed, and the TypeScript, .NET, Elixir, Ruby, and JVM drivers.
203
+ - Updated release toolchain setup and expanded release-canary coverage for wrapper dispatch.
204
+
205
+ ### Fixed
206
+
207
+ - Audit treats SQL parse gaps as operational failures even when a rule is disabled, filtered, or
208
+ invoked with `--exit-zero`.
209
+ - Native Cargo is used for macOS release targets, and generated Kotlin Exposed fixture output and
210
+ import assertions are synchronized with the upgraded driver.
211
+
212
+ ## [0.18.2] - 2026-09-23
213
+
214
+ ### Fixed
215
+
216
+ - Array element types written in the qualified form (for example `INT ARRAY`) are normalized
217
+ correctly after the sqlparser 0.63 upgrade.
218
+
219
+ ### Security
220
+
221
+ - Updated `rustls` to 0.23.45 to resolve RUSTSEC-2026-0285.
222
+
223
+ ## [0.18.1] - 2026-08-22
224
+
225
+ ### Added
226
+
227
+ - A GitHub Marketplace setup action installs checksum-verified release binaries through the moving
228
+ `Goldziher/scythe@v0` tag, with version pinning, optional caching, and installation metadata
229
+ outputs.
230
+ - A native Poly producer catalog exposes all six Scythe hooks through guarded system and pinned
231
+ Cargo execution paths.
232
+
233
+ ### Fixed
234
+
235
+ - The Go integration fixture and harness now exercise nullable PostgreSQL composite fields with the
236
+ generated pointer encoder instead of leaving that path uncompiled.
237
+ - Kysely camel-case generation now matches the plugin's recursively transformed nested JSON keys.
238
+
239
+ ## [0.18.0] - 2026-08-22
240
+
241
+ **Upgrading**: pass the field nullability as the third argument to
242
+ `CompositeFieldDefinition::new`, add `nullable` to `CompositeFieldInfo` values and serialized
243
+ metadata, and initialize the new `SchemaDescription.composites` field. Prefer
244
+ `SchemaDescription::new()` or `..SchemaDescription::new()` for forward-compatible construction.
245
+
246
+ ### Added
247
+
248
+ - Schema-defined SQL functions participate in catalog analysis, overload resolution, fingerprints,
249
+ placeholder typing, and set-returning function expansion.
250
+ - PostgreSQL live catalogs include standalone composite types and report composite schema drift via
251
+ `SC-DRF08` through `SC-DRF13`.
252
+ - `typescript-pg`, `typescript-postgres`, and PostgreSQL Kysely generate typed nested JSON result
253
+ interfaces for whole-row JSON aggregates.
254
+ - Release automation verifies every platform archive and checksum before advancing the floating
255
+ `v0` tag.
256
+
257
+ ### Changed
258
+
259
+ - Composite fields carry required nullability metadata through catalogs, analyzed queries, generated
260
+ models, and provenance fingerprints. Serialized metadata without `nullable` is rejected.
261
+ - Repository builds use the pinned Rust 1.97.1 toolchain across all five release targets.
262
+
263
+ ### Fixed
264
+
265
+ - Removed dormant vulnerable Rust dependency chains from MSSQL conformance without changing its
266
+ TLS coverage.
267
+
268
+ ## [0.17.0] - 2026-08-20
269
+
270
+ This release adds execution-backed catalogs for embedded databases, expands typed PostgreSQL
271
+ code generation, and closes the composite-parameter runtime gap across every PostgreSQL backend.
272
+
273
+ ### Added
274
+
275
+ - `php-pdo` and `php-amphp` decode PostgreSQL nested JSON rows into readonly generated objects.
276
+ JSON `numeric` fields use PHP `float` values and therefore follow binary floating-point precision.
277
+ - Schema blocks can select execution-backed catalog construction for SQLite and DuckDB. SQLite DDL
278
+ runs through `rusqlite`; DuckDB DDL runs with external access and extension loading disabled.
279
+ - A validated public catalog builder preserves inspected names, raw types, relation and generated
280
+ column kinds, and produces deterministic metadata-aware fingerprints.
281
+
282
+ ### Fixed
283
+
284
+ - PostgreSQL composite parameters are encoded and bound correctly across the generated backends.
285
+ - DuckDB schema execution preserves valid same-label enums conservatively and redacts SQL text from
286
+ execution errors.
287
+ - Java, Kotlin, and C# composite casts use token-aware placeholder rewriting.
288
+ - The documentation site uses `nanoid` 3.3.18, resolving its high-severity advisory.
289
+
290
+ ### Tests
291
+
292
+ - A live Kysely project verifies `CamelCasePlugin` result-key conversion.
293
+ - The PostgreSQL integration matrix covers composite parameter round trips.
294
+ - Release CI builds and size-checks bundled-DuckDB binaries on five supported targets.
295
+
296
+ ## [0.16.1] - 2026-08-20
297
+
298
+ This stabilization release fixes three generated TypeScript/JavaScript failures, accepts PostgreSQL
299
+ trigger definitions that sqlparser cannot represent correctly, and closes gaps in generated-code
300
+ validation. Integration harnesses now apply the same schema files used by code generation, while the
301
+ Java and Kotlin harness templates share canonical lifecycle and test-program macros without changing
302
+ their generated output.
303
+
304
+ ### Fixed
305
+
306
+ - PostgreSQL schemas containing `EXECUTE FUNCTION` or `EXECUTE PROCEDURE` trigger arguments no
307
+ longer block catalog construction. Trigger definitions are skipped because they do not contribute
308
+ catalog state; surrounding tables and functions remain available. (#238)
309
+ - `javascript-duckdb` qualifies `DuckDBBlobValue` through the DuckDB Node API in JSDoc output. (#230)
310
+ - `typescript-postgres` guards nullable composite parameters, binds JSON through `sql.json`, and uses
311
+ the driver's `JSONValue` type. The backend now passes the torture-project TypeScript check. (#231)
312
+ - TypeScript and C# integration harnesses execute their selected schema fixture instead of maintaining
313
+ inline copies of its DDL. (#234)
314
+
315
+ ### Changed
316
+
317
+ - Java and Kotlin integration templates now centralize lifecycle and test programs in parameterized
318
+ macros. Regenerated JVM harnesses remain byte-identical. (#235)
319
+
320
+ ### Tests
321
+
322
+ - Generated output from `rust-tiberius` and `rust-sibyl` now receives the same `syn` syntax gate as
323
+ the other Rust backends. (#229)
324
+ - `javascript-mssql` reconstructs explicit result objects so strict JSDoc checking validates row
325
+ shapes; a mutation test proves incorrect emitted keys are rejected. (#233)
326
+
327
+ ## [0.16.0] - 2026-08-15
328
+
329
+ 0.15.0 shipped fixes only and moved everything that was coverage debt or a feature into this
330
+ release, so 0.16.0 is the mixed one: four bugs, six gates, and the two features outside users asked
331
+ for.
332
+
333
+ Three of the bugs turned out to be one. The analyzer used the string `"unknown"` as an in-band
334
+ sentinel for "nothing resolved this", and when it escaped into codegen the user got
335
+ `INTERNAL_ERROR: unknown neutral type: unknown` — which reads as "file a bug" for input scythe had
336
+ diagnosed perfectly well. A set-returning function in the SELECT list, `array_agg(ROW(a, b))` and a
337
+ UNION whose arms widened in the wrong order were three symptoms of the same thing. The sentinel now
338
+ leaves the analyzer as a real `UNRESOLVED_TYPE` diagnostic naming the column or the parameter and,
339
+ where one exists, the form that works instead.
340
+
341
+ The gates are the shape 0.15.0 spent itself on, one layer further out: a check whose failure path is
342
+ unreachable. A fixture suite that skipped every assertion when codegen errored. A compile-check
343
+ script that exits 0 when project discovery finds nothing. A schema comparison that degrades to
344
+ comparing two empty lists. A generator that warned and succeeded on zero fixtures. Two suites that
345
+ run a real interpreter over generated code, and reported success when the interpreter was missing.
346
+ A dependency audit that could not see an optional-feature-only dependency, because `cargo deny
347
+ check` uses the default feature set. And `field_case`, honoured by sixteen backends, whose every
348
+ assertion was on a generated string rather than on a row a database returned.
349
+
350
+ On the feature side, `json_agg(json_build_object(...))` now infers a struct from the call's own keys
351
+ instead of degrading to flat `json`, and `FILTER (WHERE ... IS NOT NULL)` — the idiom for
352
+ suppressing the `[null]` a LEFT JOIN miss produces — is recognized rather than ignored. Six more
353
+ TypeScript backends gained a `javascript-*` JSDoc emit mode.
354
+
355
+ **Upgrading**: two nested-aggregate changes move types in code that already worked. A query using
356
+ `json_agg(json_build_object('id', o.id, ...))` previously generated a flat JSON value and now
357
+ generates a struct, so anything hand-typed on the receiving end needs updating. A query using
358
+ `json_agg(o.*) FILTER (WHERE o.id IS NOT NULL)` previously produced an optional element and now
359
+ produces a non-optional one — `Vec<Option<T>>` becomes `Vec<T>`, and the equivalent in every other
360
+ language. Separately, a query whose result column or parameter has no nameable type now fails at
361
+ analyze time with `UNRESOLVED_TYPE` instead of reaching codegen; such queries never generated
362
+ working code, but the error now arrives earlier and from a different layer. Fixture authors: the
363
+ `config.naming` and `config.type_overrides` keys are now load errors, and
364
+ `testing_data/00-FIXTURE-SCHEMA.json` is gone — `tools/test-generator/src/fixture.rs` is the schema.
365
+
366
+ ### Security
367
+
368
+ - **Every PHP integration harness created an order and never checked it was the one returned.**
369
+ The same defect fixed for all 13 Python harnesses in 0.15.0 was left live in all 9 PHP ones:
370
+ `test_create_order` returns the new row's id and `test_get_orders_by_user` ignored it, asserting
371
+ only the first result's `notes`, so a query returning someone else's order still passed.
372
+ `test_get_orders_by_user` now takes the created `order_id` and asserts it is among the returned
373
+ rows. (#112)
374
+
375
+ ### Fixed
376
+
377
+ - **The `python-psycopg3-msgspec` harness never checked its rows were msgspec structs.** The
378
+ project exists to prove the `row_type = "msgspec"` codegen option works, and its Pydantic twin
379
+ carries seven assertions — a dedicated row-type test plus five `isinstance` checks — while the
380
+ msgspec harness had none; `import msgspec` was the only trace of it, unused. It now mirrors the
381
+ Pydantic assertions. Three unconditional imports (`asyncio`, `Decimal`, `msgspec`) that were
382
+ unused on some engine branches are now emitted only where used, so the generated Python harnesses
383
+ are `F401`- and `I001`-clean. (#112)
384
+
385
+ - **Every codegen assertion in the fixture-generated test suite was skipped when codegen errored.**
386
+ One line in the generator wrapped each backend loop in `if let Ok(generated) = …`, producing 273
387
+ skip-guards across 13 files that between them discarded the result of **4993**
388
+ `generate_with_backend` calls. Backend *construction* failure already panicked; generation failure
389
+ one line later did not — and `generate_generated_code_assertions`, added in 0.15.0 specifically to
390
+ stop assertions being dropped, was emitted *inside* that guard, so the fix for dropped assertions
391
+ was itself dropped. A codegen error now fails the test naming the backend, engine, fixture and
392
+ error. A fixture may declare an expected failure via `expected.codegen_errors`, which requires a
393
+ written reason and fails in both directions: an undeclared failure fails, and a declared failure
394
+ that now succeeds fails as stale. No fixture currently declares one — measured across all 4993
395
+ combinations, none fail. (#222)
396
+
397
+ - **A set-returning function in the select list, and a multi-field `ROW(...)`, passed analysis and
398
+ then failed every backend with `INTERNAL_ERROR: unknown neutral type: unknown`.**
399
+ `SELECT jsonb_each(data) FROM documents` and `SELECT array_agg(ROW(o.id, o.total)) FROM orders o`
400
+ both reported an internal error — "file a bug against scythe" — for input scythe had diagnosed
401
+ perfectly well. PostgreSQL's anonymous `record` and a bare multi-field row genuinely have no
402
+ neutral type, but that is a fact to report, not an internal fault. Both now fail at analyze time
403
+ with `UNRESOLVED_TYPE`, naming the column and the construct; the set-returning-function message
404
+ points at the `FROM`-clause form (`FROM documents, jsonb_each(data) AS kv`), which already
405
+ resolves to real `key` and `value` columns. The same treatment covers `json_each_text`, the
406
+ `json_populate_record` family, `unnest` over a non-array, and nine other expression shapes that
407
+ previously reached codegen as a bare `"unknown"`. (#223)
408
+
409
+ - **An unresolved marker wrapped in a container leaked its internal spelling to the user.**
410
+ `SELECT array_agg(bogus_fn(id)) FROM t` reported
411
+ `INTERNAL_ERROR: unknown neutral type: __unknown_func__:bogus_fn` — scythe's own internal marker,
412
+ verbatim. The markers that stand for "ambiguous column", "unknown column" and "unknown function"
413
+ were matched only at the start of a neutral type, so `array_agg` wrapping one as
414
+ `array<__unknown_func__:…>` slipped past every check. This is the #173 failure mode the marker
415
+ family's own doc comment warns about, still live for the container case. It now reports
416
+ `UNKNOWN_FUNCTION: function "bogus_fn" does not exist`.
417
+
418
+ - **Two CLI integration tests gated their generated output on its byte count.**
419
+ `test_generate_pagila_writes_file`'s entire body, after checking the file existed, was
420
+ `content.len() > 500` — pagila generates 7016 bytes, so the check permitted losing 93% of it, and
421
+ `test_generate_writes_file`'s `> 100` was no better. Both now assert that every query in the
422
+ fixture produced a named function, and that the file defines exactly that many and no more; the
423
+ count is what catches two queries collapsing onto one name, which a presence check cannot see.
424
+ (#161)
425
+
426
+ - **A composite-typed query parameter was bound to postgres.js as a whole object, so
427
+ `typescript-postgres` output did not type-check** (`TS2345: 'TortureAddress | null' is not
428
+ assignable to 'ParameterOrFragment<never>'`). The codegen that renders `ROW(a, b)::type_name` for
429
+ a bound composite was already correct but never ran: it looks the composite up in
430
+ `analyzed.composites`, and the analyzer's composite worklist seeded itself from a query's columns
431
+ and nested-struct fields but never from its params. A composite bound only as a parameter — an
432
+ `INSERT` whose composite column never appears in `RETURNING` — therefore never reached that list
433
+ at all, and the emitter took its silent whole-object fallback. The worklist now chains params the
434
+ way the enum scan beside it always did, and `typescript-pg` compiles the torture project as a
435
+ result. `typescript-postgres` still does not: with the composite reaching the emitter, two further
436
+ defects in that backend became visible — a nullable composite param dereferences null, and a
437
+ `jsonb` param binds as a raw object postgres.js rejects. Its
438
+ `scripts/torture-expected-failures.txt` entry has been restored with those reasons and now points
439
+ at #231. (#225)
440
+
441
+ - **A `UNION` whose `NULL`-projecting arm came first failed type resolution instead of widening.**
442
+ `SELECT id AS tag FROM accounts UNION SELECT NULL AS tag FROM users` compiled; swapping the arms
443
+ produced `INTERNAL_ERROR: type resolution failed for column 'tag': unknown neutral type: unknown`.
444
+ `widen_union_arm_type`'s non-nested fallthrough called `widen_type` directly, and `widen_type`
445
+ returned its left argument for any pair its numeric ladder does not handle — so an `unknown` arm
446
+ on the left won over the other arm's real type. `widen_type` now absorbs `unknown` from either
447
+ position, and the call site routes through `widen_neutral_type`, the helper whose own doc comment
448
+ names it the single rule every widening call site must use (#121) and which every other call site
449
+ already used. `UNION` is commutative, so both spellings now agree. Reported and fixed by
450
+ @snowyukitty in #227. (#224)
451
+
452
+ - **An internal type marker still reached the user, through query parameters.** The fix for this
453
+ defect covered result columns only. A placeholder inside a function whose result has no nameable
454
+ type adopts that result as its own type, and nothing rejected it afterwards, so
455
+ `SELECT id FROM documents WHERE data::text = COALESCE($1, ROW(id, data))::text` reported
456
+ `INTERNAL_ERROR: type resolution failed for param 'row': unknown neutral type:
457
+ __untypeable_row__:` -- scythe's internal marker spelling, verbatim, in front of a user. It now
458
+ reports the same actionable `UNRESOLVED_TYPE` diagnostic the column path does, naming the
459
+ parameter. `GREATEST`/`LEAST`, `NULLIF` and `CASE` reached it the same way. (#223)
460
+
461
+ - **`field_case` had no runtime assertion anywhere.** Sixteen backends honour the option
462
+ (`apply_field_case_option`), but every existing assertion was on a generated string, never on a
463
+ row a database actually returned. The new `typescript-pg-camel` integration project drives a
464
+ real `pg` query with `field_case = "camelCase"` and asserts on the live row object: the remapped
465
+ `userId` key is present with the expected value, and the original `user_id` key is gone — the
466
+ negative check is the point, since a backend that adds the camelCase key while leaving the
467
+ snake_case one in place would pass a positive-only check. `typescript-kysely` is not covered: it
468
+ deliberately does not remap, relying on the caller registering `CamelCasePlugin`, so its camelCase
469
+ keys come from the driver rather than from generated code and the harness has to register the
470
+ plugin to assert anything — tracked as #228. (#92)
471
+
472
+ - **Three gates reported success for having checked nothing.** `check-generated-backends.py`,
473
+ which compile-checks every backend against the torture schema, exits 0 when project discovery
474
+ returns nothing: its pass/fail flag is only cleared by lists derived from the discovered set. An
475
+ allowlist entry naming a vanished project used to catch that by accident, and that backstop went
476
+ inert when the last active entry was deleted. `schema_variant_consistency` compares two schema
477
+ files through a parser that recognises only a literal `CREATE TABLE` line, so any restyling it
478
+ stops recognising hits both files at once and reduces the comparison to two empty lists. And
479
+ `test-generator` warned and exited 0 on zero fixtures, leaving the committed tree untouched so
480
+ CI's freshness check reported everything fresh — its own vacuity guard counts committed files,
481
+ which are still there. All three now fail. (#196)
482
+
483
+ - **A missing interpreter silently deleted two suites' only real check.**
484
+ `composite_text_escaping_regression.rs` runs the emitted composite parser against the exact text
485
+ PostgreSQL 16 produces, and `sql_literal_injection_regression.rs` compiles every backend's
486
+ escaped literal with that language's real compiler — both precisely because the string match they
487
+ sit next to cannot tell a correct branch from a plausible-looking one. When the interpreter or
488
+ compiler was absent, both returned early and reported success, degrading to the string match they
489
+ exist to supersede. Under `SCYTHE_VALIDATE_STRICT` (set for CI's `cargo test --workspace`) the
490
+ skip is now a failure naming the missing tool; locally it still skips, since nobody has all ten
491
+ toolchains. (#127)
492
+
493
+ - **A per-query codegen error in the real-tool harness was swallowed, and the harness kept going.**
494
+ `tool_validation.rs` generates three queries per backend and then ran every structural and
495
+ real-compiler check over whatever subset happened to succeed, logging the rest to a captured
496
+ stderr. A backend that broke only on `QUERY_ONE` -- the query carrying the array, enum-in-array,
497
+ composite, `uuid` and `jsonb` columns, i.e. the one worth checking -- still produced a struct and a
498
+ function from the other two and passed. The nominal backstop, `assert!(!code.trim().is_empty())`,
499
+ cannot fail: `provenance::assemble_file` always prepends a non-empty provenance header no matter
500
+ how many query bodies survived. A codegen error now panics, naming the backend and the failing
501
+ query. The same file's exemption list also claimed all four Rust backends were "still
502
+ syntax-checked by `syn::parse_file` elsewhere"; only two are, since the generated suite gates that
503
+ call on `rust-sqlx` and `rust-tokio-postgres` by name and `compile_check.rs` reaches `rust-sqlx`
504
+ alone. The comment now states the real coverage. (#229)
505
+
506
+ ### Added
507
+
508
+ - **`javascript-node-sqlite`: a JSDoc emit mode for `typescript-node-sqlite`.** The fifth
509
+ `javascript-*` backend (alongside `javascript-postgres`, `javascript-pg`, `javascript-mysql2`,
510
+ `javascript-better-sqlite3`): plain, JSDoc-annotated `.js` output for Node's built-in
511
+ `node:sqlite` module, checked against real `node --check` and `tsc --checkJs --strict` in CI.
512
+ `node:sqlite` is synchronous, like `better-sqlite3`, so this mirrors
513
+ `javascript-better-sqlite3`'s emit shape rather than the `async` pg/postgres.js/mysql2 one, except
514
+ for `:batch`: `DatabaseSync` has no `.transaction()` helper, so the generated code wraps explicit
515
+ `BEGIN`/`COMMIT`/`ROLLBACK` statements, matching `typescript-node-sqlite`'s own TS-mode `:batch`
516
+ shape.
517
+
518
+ - **The `javascript-*` backends' `:many` output is now type-checked by real `tsc`.** The JS-mode
519
+ tool-validation fixture built only a `:one` and a `:grouped` query, so the one command whose JSDoc
520
+ cast is not a plain one-step assertion was pinned by hand-written string matching alone, on all
521
+ five backends. It now builds a `:many` query too. (#93)
522
+
523
+ - **`javascript-wasm-sqlite` and `javascript-snowflake`: two more JSDoc emit modes.** The sixth and
524
+ seventh `javascript-*` backends. `javascript-wasm-sqlite` mirrors `javascript-better-sqlite3`'s
525
+ synchronous shape (`@sqlite.org/sqlite-wasm`'s OO1 API is sync, and the driver's one-time async
526
+ `sqlite3InitModule()` stays entirely outside generated code); unlike the sync sqlite backends
527
+ already shipped, its single-row *and* array casts are both genuine `tsc` `TS2352`s as a TypeScript
528
+ `as`, but the JSDoc `/** @type {T} */ (...)` spelling of both is accepted, verified against real
529
+ `tsc --checkJs --strict`, so it never needs the TS path's `unknown` hop. `javascript-snowflake` is
530
+ the first `javascript-*` backend whose `file_header` is not empty: `normalizeRow`, the runtime
531
+ helper the generated query bodies call to lowercase Snowflake's uppercase column names, has to stay
532
+ in JSDoc mode too (re-typed via a JSDoc block), and only the TS-only `import type { Binds,
533
+ Connection }` line drops. Its `binds` cast is the one JSDoc cast across all seven backends that
534
+ still needs the `unknown` hop -- `Binds`'s declared type does not admit every parameter type this
535
+ backend can emit, and that failure reproduces identically whether the cast is written `as` or
536
+ `/** @type */`. (#93)
537
+
538
+ - **`javascript-duckdb`, `javascript-oracledb` and `javascript-mssql`: the last three JSDoc emit
539
+ modes.** Ten of the eleven TypeScript backends now have a `javascript-*` counterpart.
540
+ `typescript-kysely` is the one left out, and deliberately: JSDoc has no way to spell `Kysely<DB>`.
541
+ Two of the three break the family's "no driver import" rule for a real reason -- `mssql` and
542
+ `oracledb` generated bodies read driver constants (`sql.Int`, `oracledb.BIND_OUT`) as runtime
543
+ values and not merely as types, so the import stays live in JS mode and the handle types are
544
+ `sql.ConnectionPool` / `oracledb.Connection` rather than the inline `import("...")` spelling the
545
+ other eight use. `javascript-oracledb` carries its TypeScript counterpart's identifier
546
+ case-folding (#218) into every JS-mode row read, not just into the type annotations.
547
+ `javascript-mssql` is the one backend in the family whose row read carries no JSDoc cast at all:
548
+ `mssql`'s typed `query<Entity>()` needs an explicit type argument that JSDoc cannot supply at a
549
+ call site, and the untyped overload returns `any`, so `tsc` checks nothing there and the
550
+ string-content assertions are the only guard -- recorded here because it is a real weakness in
551
+ this backend's verification, not an oversight. (#93)
552
+
553
+ - **`json_agg(json_build_object(...))`/`jsonb_agg(jsonb_build_object(...))` now infer an inline
554
+ nested field list.** The relation-argument form (`json_agg(o.*)`) already synthesized a struct;
555
+ the inline-object form — what people actually write when the columns they want are not a whole
556
+ table — fell back to flat `json`. Field names come from the call's own string-literal keys, and
557
+ field nullability follows each value expression's real type, including outer-join widening.
558
+ Confirmed against PostgreSQL 16: `json_build_object` is not strict, so the built object is never
559
+ itself SQL NULL — not even for the phantom all-NULL row a LEFT JOIN miss produces — so unlike the
560
+ relation-argument form, elements here are never wrapped `nullable<>`; only individual fields are.
561
+ Also recognizes the standard `FILTER (WHERE {alias}.{col} IS NOT NULL)` idiom (optionally
562
+ `AND`-conjoined) on the relation-argument form: it provably excludes that phantom row regardless
563
+ of which column of the relation it names, so the array element is no longer marked nullable when
564
+ the filter is present. (#78)
565
+
566
+ ### Changed
567
+
568
+ - **Every integration harness now applies the same schema file its `scythe.toml` generated from.**
569
+ `schema_file` reached `scythe.toml.jinja` and one Kotlin branch; the other ~16 sites across 11
570
+ harness templates hardcoded a filename per engine, and `SCHEMA_FILE_OVERRIDES` was keyed by
571
+ backend name so it covered only the 2 backends that happened to already agree. 7 of 9 Oracle
572
+ projects and all 14 Redshift projects generated code from `schema.sql` while their harness created
573
+ the database from `schema_full.sql` / `schema_pg_compat.sql`. The override table is now keyed by
574
+ engine, which is the thing that actually determines the answer, so it cannot go stale when a
575
+ backend is added for an engine already listed. No inferred type changes — the two schema variants
576
+ agree today, which is exactly why this stayed invisible; only the recorded schema hash moves.
577
+ (#196)
578
+
579
+ - **The generated-type check now covers 10 of 13 Python and 10 of 10 PHP integration projects**, up
580
+ from 5 and 2. The three Python projects still excluded use `aiomysql` or `pyodbc`, neither of
581
+ which ships type information, and are documented in place rather than wired up to a checker that
582
+ cannot fail on them. Every expected-error count is measured, not assumed, and the eight PHP
583
+ projects that newly run `composer install` in CI have committed lock files so the install is
584
+ pinned. `python-duckdb` joins the loop: the comment excluding it claimed it had no
585
+ `integration_tests/` project directory, which stopped being true several releases ago. (#127)
586
+
587
+ ### Removed
588
+
589
+ - **`testing_data/00-FIXTURE-SCHEMA.json`**, the JSON Schema `CONTRIBUTING.md` pointed contributors
590
+ at. It had drifted far enough to reject every current fixture: it required `rust_type` where the
591
+ loader reads `type`, named `generated_rust` where the loader reads `generated_code`, listed 3
592
+ engines against the loader's 9, and defined no `lint` key under `additionalProperties: false`. A
593
+ hand-maintained mirror of the loader is exactly what drifted, so it is gone rather than
594
+ re-synchronised — `tools/test-generator/src/fixture.rs` is the schema, and its
595
+ `#[serde(deny_unknown_fields)]` structs already fail a bad fixture by naming the offending key.
596
+
597
+ - **The `config.naming` and `config.type_overrides` fixture keys.** Both were deserialized and never
598
+ read. Zero fixtures declared `naming`. One declared `type_overrides` — with `lang_type` and `json`
599
+ fields that do not exist in the real `[[type_overrides]]` shape `scythe-cli` reads (`column`,
600
+ `db_type`, `type`), so it was never a silently-ignored feature, just a shape that had never been
601
+ wired to anything. What that fixture actually proves — a JSON column mapped to a typed struct — is
602
+ asserted independently through its `@json` annotation. Both keys are now load errors. (#156)
603
+
604
+ ## [0.15.0] - 2026-08-15
605
+
606
+ This release is mostly about checks that could not fail. A validator whose only callers were its own
607
+ tests, an allowlist nobody reconciled, a CI step whose assertion was vacuous, a fixture that asserted
608
+ only that *something* was generated — each one reported success while measuring nothing, and several
609
+ had done so since the feature they guarded shipped. Auditing them found real defects underneath:
610
+ generated Rust whose bytes depended on whether `rustfmt` happened to be on `PATH`, two queries whose
611
+ names collapsed onto one function, a nested aggregate quietly degraded to an opaque string, and a
612
+ `ruby-pg` signature promising a `Hash` for a value that was the driver's raw wire text.
613
+
614
+ A second shape recurred often enough to name: the test that pins the bug. Several tests asserted the
615
+ *defective* output verbatim, so they failed when someone fixed the thing they were named after. Those
616
+ are inverted here, each with a doc comment stating what it now guards.
617
+
618
+ Nullability, JVM enum round-trips, `?` placeholder counting and Oracle's LOB reads were all measured
619
+ against live PostgreSQL, MySQL, MariaDB and Oracle rather than against scythe's own model. Four
620
+ backends that had never executed anywhere — `kotlin-exposed` among them — now run in CI, and running
621
+ them found seven defects no string-matching test could reach.
622
+
623
+ **Upgrading**: three changes can turn a config that used to be accepted into an error. `[lint.sqruff]`
624
+ is now actually read, so a table that was previously inert may now fail the run; keys in a `[[sql]]`
625
+ block that scythe does not define are now rejected instead of ignored; and Ruby `.rbs` output changes,
626
+ so committed signatures need regenerating. `scythe-codegen`'s public `generate_from_catalog` stub is
627
+ also removed (#132) — a breaking change for any direct caller, though it had none in this repository.
628
+ Two lint-crate suppression and audit APIs also changed shape (see **Fixed**): `SuppressionSet` is now
629
+ keyed by statement index instead of source line, and `LintRule` gained `cwe()` / `is_applicable_to()`
630
+ methods with safe defaults. `scythe-lint` also drops four `sqruff_adapter` free functions in favour of
631
+ building a `SqruffLinter` once (see **Removed**). `scythe-core`'s public `CustomAnnotation` struct
632
+ gained a `suggested_keyword: Option<String>` field (see **Fixed**, #152) — a breaking change for any
633
+ direct caller that builds one by struct literal rather than through the parser. Details below.
634
+
635
+ ### Security
636
+
637
+ - **`SC-RLS02` (`policy-always-permissive`) reported a deny-all RLS policy as granting
638
+ unconditional access.** `WITH CHECK (NULL)` / `USING (NULL)` reject every row — NULL is not
639
+ TRUE — but the rule's tautology check folded `NULL` in alongside `true` and `1=1`, so the most
640
+ restrictive policy possible was flagged at `error` severity with remediation advice ("replace
641
+ the tautology with an actual predicate") that would have *loosened* security in response to a
642
+ security finding. `NULL` is no longer treated as a tautology by this rule; `SC-CHK01`
643
+ (`check-constraint-always-true`), where `NULL` genuinely does satisfy a CHECK constraint, is
644
+ unaffected. (#139)
645
+ - **Every Python integration harness created an order and never checked it was the one returned.**
646
+ `test_create_order` returns the new row's id, but `test_get_orders_by_user` ignored it and only
647
+ asserted the first result's `notes`, so a query that returned someone else's order (or the wrong
648
+ row) would still pass. `test_get_orders_by_user` now takes the created `order_id` and asserts it
649
+ is present in the returned rows, in all 13 Python harnesses. (#112)
650
+
651
+ - **`java.java.jinja` and `kotlin.kt.jinja`'s non-postgresql engine branches were missing tests for
652
+ queries their own fixtures already defined.** GH #195/#196's parity gate (`10066723`) made the
653
+ drift visible via `test-parity-exemptions.txt` but left the 44 "never wired up" gaps open;
654
+ `UpdateUserEmail` and `SearchUsers` are now called from every engine branch in both templates,
655
+ `GetOrderTotal` from every branch that didn't already have it (duckdb, mssql, redshift,
656
+ snowflake, sqlite), and `ListActiveUsers` from redshift's. Redshift's `SearchUsers` and
657
+ `ListActiveUsers` queries filter by `status`, not a name `LIKE` pattern like every other engine —
658
+ its ported tests call them with a status value rather than `"%Alice%"`, matching what
659
+ `queries/users.sql` actually defines for that engine. The 44 closed exemption lines are deleted;
660
+ the 48 remaining entries are all structural (a `UserStatus` enum parameter or the nullable
661
+ composite-column read from board #197 with no per-engine equivalent) and are unchanged.
662
+
663
+ ### Added
664
+
665
+ - **`kotlin-exposed` has a running integration project, and running it found seven defects.** The
666
+ backend had shipped since 0.6.0 with nothing ever executing its output, and none of the seven was
667
+ reachable by a string-matching test: the generated file declared no `package generated`, so any
668
+ caller importing it failed outright; an enum parameter was bound as the Kotlin enum object rather
669
+ than its SQL spelling; those parameters then needed an explicit `::<enum type>` cast, because
670
+ Exposed sends a typed `character varying` that PostgreSQL will not coerce to a user enum;
671
+ `:exec_rows` and `:exec_result` read a row count off `Transaction.exec`, which returns `Unit`, so
672
+ they never compiled; a `RETURNING` query ran as an `INSERT` and the driver raised "A result was
673
+ returned when none was expected", now fixed with an explicit `StatementType.SELECT`; the bind list
674
+ was an unannotated `listOf(...)` whose type inference collapsed on a heterogeneous parameter set;
675
+ and `UUIDColumnType` was emitted but never imported. The project runs 14 assertions in CI,
676
+ including the composite-escaping and nullable-enum reads. (#213, #214)
677
+
678
+ - **`java-r2dbc` and `kotlin-r2dbc` have running integration projects on PostgreSQL.** Both backends
679
+ shipped with nothing executing their output, and running them found defects no string-matching
680
+ test could see: an enum parameter was bound as the Java/Kotlin enum object, which
681
+ r2dbc-postgresql cannot encode, and once bound as its SQL spelling the server rejected the
682
+ untyped `character varying` against a `user_status` column. Enum placeholders now carry an
683
+ explicit `::<enum type>` cast on PostgreSQL, so the generated code needs no `EnumCodec`
684
+ registration from the caller. The MySQL, MariaDB and SQLite pairs stay uncovered, each with a
685
+ measured reason recorded in `tools/integration-test-generator/coverage-exemptions.txt`.
686
+
687
+ - **`php-amphp` on MySQL and `typescript-kysely` on Redshift now have integration projects that
688
+ actually run in CI.** Both manifests shipped with nothing exercising them. `php-amphp-mysql`
689
+ immediately found two real defects — the harness's `MysqlConfig::fromArray()` does not exist, and
690
+ the generated pool type made `LAST_INSERT_ID()` unreliable (see **Fixed**) — which is the whole
691
+ point of the exemption list these two came off. `typescript-kysely-redshift` gates the queries
692
+ Redshift's fixture does not define and reads `status` as a varchar rather than an enum, matching
693
+ what the `pg` and `postgres` drivers already did for that engine.
694
+
695
+ - **`rust-tokio-postgres` can read and write range columns.** The manifest previously declared no
696
+ `range` mapping at all, because `postgres-types` ships no `Range<T>` with a `FromSql`/`ToSql`
697
+ impl the way `sqlx-postgres` does, and the mapping it used to carry (`String`) could not decode:
698
+ `String`'s `accepts()` matches no range OID, so `row.get` panicked before `from_sql` ran. The
699
+ backend now emits a hand-rolled `PgRange<T>` built on `postgres_protocol::types::range_from_sql`
700
+ / `range_to_sql` — the same wire-format primitives `postgres-types` uses internally for arrays —
701
+ gated on a generated fragment actually naming `PgRange<`, so a file with no range column does not
702
+ carry it. `Empty` is a distinct variant from a fully-unbounded range rather than collapsed into
703
+ it, because the two are different values on the wire and collapsing them would make an empty
704
+ range decode as if it contained everything. Verified against live PostgreSQL across bounded,
705
+ empty, unbounded and both binding directions; note that no schema in this repository has a range
706
+ column yet, so no CI job compiles the emitted wrapper. (unfiled)
707
+
708
+ - **Integration coverage for nullable enum and nullable composite columns.** No integration project
709
+ had ever selected a composite column, so the entire runtime read path was unexercised while
710
+ codegen compiled green. The PostgreSQL schema gains a `user_address` composite and two nullable
711
+ columns, and a `GetUserProfile` query asserts both a present value and a SQL NULL — the shape
712
+ that catches a reader which decodes NULL as a zero-valued variant or an all-default struct.
713
+
714
+ Running it revealed that composite decoding is implemented in only four of the fifteen PostgreSQL
715
+ backends: `rust-sqlx` and `rust-tokio-postgres`, which get it from their drivers' derive macros,
716
+ and `java-jdbc` and `kotlin-jdbc`, which parse the composite text form. In the other eleven the
717
+ generated row type declares the composite struct while the driver's raw value is assigned straight
718
+ through, so the annotation is wrong at runtime — `php-pdo`, `php-amphp` and `csharp-npgsql` throw,
719
+ and `python-psycopg3`, `python-asyncpg`, the `typescript-pg` family, `ruby-pg`, `elixir-postgrex`,
720
+ `elixir-ecto` and `go-pgx` return a raw string, a driver record, or `undefined` with no error at
721
+ all. The new assertions are therefore scoped to the four backends that work, with each excluded
722
+ language's template carrying a note to restore them once that backend learns to parse a composite,
723
+ so the gap is explicit rather than a green suite that proves nothing. (unfiled)
724
+
725
+ - **`scythe inspect` now has a real MySQL/MariaDB driver.** Live inspection was PostgreSQL-only;
726
+ every other engine fell through to a stub that reported itself as `mysql` regardless of what the
727
+ user asked for. `MySqlDriver` (backed by `mysql_async`) ships four checks driven by its own
728
+ `mysql/checks.toml`, merged into the canonical registry alongside PostgreSQL's: `SC-INS-MY01`
729
+ (no primary key), `SC-INS-MY02` (duplicate index), `SC-INS-MY03` (`AUTO_INCREMENT` past 70% of its
730
+ type range), `SC-INS-MY04` (`MEMORY` storage engine). The two check sets are deliberately not
731
+ symmetric — PostgreSQL's row-level-security, extension and `SECURITY DEFINER` search-path checks
732
+ have no MySQL equivalent and are not approximated — and `verify_queries` stays PostgreSQL-only
733
+ because it depends on the extended-query protocol's describe response. SQLite, MSSQL, Oracle,
734
+ Snowflake and Redshift still get `UnsupportedDriver`, which names the engine the user actually
735
+ asked for and refuses rather than returning an empty finding set. (#131, partial)
736
+
737
+ - **`scythe generate --validate-output`** runs the generated code through the real compiler or linter
738
+ for its language and reports, per target, whether it was `VALIDATED`, `SKIPPED`, or `FAILED`.
739
+ `validate_generated_code` previously had no production caller at all — every call site outside
740
+ `validation.rs` was a test — so `generate` never checked its own output. Off by default because it
741
+ shells out to toolchains that may not be installed. A run where the validator found no tool to
742
+ invoke is reported as `SKIPPED`, never as success: reporting it as validated would recreate the
743
+ unfalsifiable gate the flag exists to close. A `FAILED` target exits 2, matching the exit-code
744
+ contract `check`/`lint`/`fmt --check` follow, where exit 1 stays reserved for operational failure.
745
+ (unfiled)
746
+
747
+ - **DuckDB integration coverage.** `python-duckdb`, `typescript-duckdb`, `java-jdbc-duckdb` and
748
+ `kotlin-jdbc-duckdb` now run in a new `integration-duckdb` CI job, against the schema and query
749
+ set added earlier in this release. DuckDB is embedded, so the job needs no service container.
750
+ `go-database-sql-duckdb` exists and its harness is written, but stays exempt: `go-duckdb` cannot
751
+ bind a nil pointer, and the backend emits `*T` for a nullable parameter, so any NULL argument
752
+ fails at runtime — measured against the driver, tracked as board #228. (#126)
753
+
754
+ - **`scythe-inspect` can read a SQLite or MySQL catalog.** A new `SchemaCatalogDriver` trait gives
755
+ catalog reading the engine seam it never had — `fetch_live_schema` was a bare function hardcoded to
756
+ `tokio_postgres::Client`. `SqliteCatalogSource` reads `sqlite_master` plus `PRAGMA table_info` and
757
+ needs no server, so it is tested in-process; `MySqlCatalogSource` reads `information_schema`, with
758
+ live tests gated the way the PostgreSQL ones already are. `ColumnDescription` gained `primary_key`.
759
+ At the time this landed, the `SC-INS` health checks were still PostgreSQL-only hand-written
760
+ `pg_catalog` SQL and the CLI was not wired to either source, so `scythe inspect`'s user-facing
761
+ behaviour was unchanged — MySQL/MariaDB got a real `SC-INS` driver and honest CLI dispatch
762
+ separately (see the "`scythe inspect` now has a real MySQL/MariaDB driver" entry above). What this
763
+ entry's `SchemaCatalogDriver` sources still are not wired into is schema drift: nothing yet feeds
764
+ `SqliteCatalogSource` or `MySqlCatalogSource` output into `diff_schemas` the way `fetch_live_schema`
765
+ is for PostgreSQL, so drift detection stays PostgreSQL-only.
766
+ - **Generated Python and PHP are type-checked in CI.** A new `validate-generated-types` job installs
767
+ each project's real driver, then runs `pyrefly check -p strict` over five Python backends and
768
+ PHPStan over both PHP ones. Every step was proven able to fail by injecting a defect first. The
769
+ `strict` preset is load-bearing — pyrefly's default `basic` preset misses a wrong return-type
770
+ annotation entirely — and the job already catches one real pre-existing bug. Ruby and Elixir were
771
+ investigated and deliberately left out rather than given a step that cannot fail: no Ruby driver
772
+ has signatures in `gem_rbs_collection` (and `rbs validate` returns 0 even for a nonexistent class),
773
+ and Dialyzer needs `dialyxir`'s translation layer, which no integration project depends on.
774
+
775
+ ### Fixed
776
+
777
+ - **The java/kotlin engine-test-parity gate never measured five of its twelve branches, and one
778
+ measured branch silently overwrote another's count.** `branch_test_names` only recognised a
779
+ top-level `if`/`elif engine == "..."` line, so `driver == "r2dbc"`-conditioned branches and
780
+ `backend == "kotlin-exposed"` were invisible to it entirely — 21 java and 35 kotlin test
781
+ functions sat outside every window it built and were excluded from every comparison without a
782
+ trace, leaving `integration_tests/java-r2dbc`, `kotlin-r2dbc`, and `kotlin-exposed` with zero
783
+ parity coverage. Separately, a nested column-0 `{% if engine == "mariadb" %}` inside
784
+ `kotlin.kt.jinja`'s r2dbc branch was mistaken for a real top-level branch, and its measured test
785
+ set was overwritten by the real `mariadb` branch's via a plain `BTreeMap::insert` with no
786
+ warning. Branch discovery now derives a key from every quoted literal a top-level condition
787
+ compares against (`r2dbc-postgresql`, `r2dbc-mysql-mariadb`, `kotlin-exposed`, alongside the
788
+ existing per-engine keys), a duplicate derived key is now a hard `panic!` naming both branch
789
+ starts instead of a silent overwrite, and a new assertion fails if any test function falls
790
+ outside every measured branch range. The newly measured `kotlin-exposed` gap was closed by
791
+ renaming a test to match its postgresql counterpart; the remaining genuine gaps (all in the two
792
+ `r2dbc` branches, one of which — mysql/mariadb — has no generated project to run it) are recorded
793
+ in `test-parity-exemptions.txt` with reasons specific to why porting isn't safe or possible yet,
794
+ taking that file from 48 entries to 60. (#195)
795
+
796
+ - **`ruby-pg` declared a `json`/`jsonb` column `Hash` in its `.rbs` but never decoded it.**
797
+ `ruby-pg.toml` maps `json = "Hash"`, but `ruby_coercion` had no arm for it, so the generated
798
+ `.rb` code read the bare `row["col"]` — the `pg` gem does no client-side JSON decoding, so
799
+ that value was the raw wire-format `String`, contradicting the `Hash[String, untyped]` its
800
+ own `.rbs` signature promised. This is the `json` sibling of #198's `decimal` bug, left open
801
+ when that fix only covered `BigDecimal`. `ruby_coercion` now wraps a `json`/`json_array`
802
+ column's value in `JSON.parse(...)`, gated behind a conditional `require "json"` the same way
803
+ `.to_d` gates `require "bigdecimal/util"`. `json_array` (the `json_agg` array shape) is a new
804
+ manifest scalar mapped to `Array`, so a degraded nested aggregate keeps declaring an `Array`
805
+ instead of falsely claiming `Hash`. (#147)
806
+
807
+ - **`php-amphp` typed its handle as `SqlConnectionPool`, which made MySQL's generated
808
+ `LAST_INSERT_ID()` lookups unreliable.** Every generated function took
809
+ `\Amp\Sql\SqlConnectionPool`, so a single `MysqlConnection` was rejected outright — but a pool is
810
+ the wrong thing to pass on MySQL: `GetLastInsertUser` resolves `LAST_INSERT_ID()`, which is scoped
811
+ to the connection that ran the `INSERT`, so the pool routes the follow-up `SELECT` to a different
812
+ connection and it finds no row. The parameter is now `\Amp\Sql\SqlExecutor`, the narrowest
813
+ interface carrying the `prepare()` the generated code actually calls; both the pool and the bare
814
+ connection implement it on PostgreSQL and MySQL alike. This is a widening — callers already
815
+ passing a pool are unaffected. Found by running the new `php-amphp-mysql` integration project.
816
+
817
+ - **`go-database-sql` on DuckDB failed at runtime on every nullable parameter.** The manifest maps a
818
+ nullable parameter to `*{T}`, and `go-duckdb` cannot bind a typed pointer at all: measured against
819
+ v2.3.3, both a nil and a *non-nil* `*string` fail with `could not bind parameter / unsupported data
820
+ type: unknown type`, while an untyped nil and a bare value both bind. So this was never limited to
821
+ NULL arguments — any query with a nullable parameter was unusable. Pointer-typed arguments are now
822
+ dereferenced at the bind site (nil becoming an untyped nil) by a generated helper, leaving the
823
+ public function signature unchanged. The other `database/sql` engines bind pointers natively and
824
+ are untouched. `go-database-sql-duckdb` now runs in the `integration-duckdb` CI job, which is what
825
+ surfaced this. (#228)
826
+
827
+ - **`ruby-oci8` handed back a LOB locator where the generated row type declared a `String`.**
828
+ OCI8 returns a lazy `OCI8::CLOB` / `NCLOB` / `BLOB` / `BFILE` handle rather than a materialized
829
+ value, so a LOB-backed field held the locator instead of its contents. Both CLOB and VARCHAR2
830
+ resolve to the neutral type `string` (and BLOB and RAW to `bytes`), so nothing at the neutral
831
+ level could tell them apart — the fix dispatches on the column's raw `sql_type`, matching what
832
+ `rust_sibyl.rs` already does for the same problem on the same engine. Applied at all seven
833
+ column-read sites, deliberately **not** to the grouped-query grouping key: a LOB's read position
834
+ hits EOF after the first `#read`, so wrapping the key would blank the field read afterwards.
835
+ Found by `ruby-oci8-oracle`'s first CI run that got far enough to execute queries. Its step is
836
+ restored and now runs last in the Oracle job, so a failure there costs only its own coverage.
837
+ Applied to the `cursor.fetch` reads only: a `RETURNING ... INTO` output bind is declared to OCI8
838
+ up front as `bind_param(n, nil, String)` and OCI8 materializes the value into that class, so
839
+ `cursor[n]` there is already a `String` and wrapping it raised `undefined method 'read' for an
840
+ instance of String` in `create_order`. The test covering that path had asserted the wrapped
841
+ spelling, so it guarded the defect instead of against it; it is inverted. (#225)
842
+
843
+ - **`ruby-oci8` called a cursor method on an integer for `:exec_rows` and `:exec_result`.**
844
+ `OCI8#exec` is polymorphic in its return: an `OCI8::Cursor` for a `SELECT`, but the number of
845
+ rows processed — a plain `Integer` — for `INSERT`/`UPDATE`/`DELETE`. The generated code bound the
846
+ result and called `.row_count` on it, which is a `Cursor` method, so `delete_orders_by_user`
847
+ raised `undefined method 'row_count' for an instance of Integer`. For DML the count is already
848
+ the return value. Surfaced by the Oracle CI job only after the LOB fix above let it run that
849
+ far. (#225)
850
+
851
+ - **A harness executing the shared schema could send several statements as one.** Every generated
852
+ harness splits `schema.sql` on `;` and runs the fragments; the split was not SQL-aware, so a
853
+ semicolon inside a string literal or a `$$`-quoted body split mid-statement. All eight templates
854
+ now split with a small state machine that tracks `'...'`, `"..."`, `$$...$$` **and `--` line
855
+ comments** — the last of those is not optional: without it an apostrophe in a comment
856
+ (`schema.sql's`) opens a phantom literal and swallows every following semicolon, which is
857
+ strictly worse than the naive split it replaced. Block comments are not handled, and each
858
+ splitter says so; no schema under `integration_tests/sql/` uses them. (#224)
859
+
860
+ - **`csharp` and `elixir` harnesses printed `PASS` for a test whose assertions had just failed.**
861
+ Same defect fixed for typescript in this release. `python`, `php` and `ruby` turned out **not**
862
+ to share it — their assertion helpers raise or throw, so the `PASS` line after a failure is
863
+ unreachable — and `go`, `java` and `kotlin` already use a passed/failed counter. In every case
864
+ the run still exited non-zero; the damage was to whoever reads the log. (#227)
865
+
866
+ - **`elixir-jamdb` generated code could not run at all.** Four independent defects, each hidden
867
+ behind the last, found by giving `elixir-jamdb-oracle` its first CI step and then fixed and
868
+ verified against a local Oracle 21c:
869
+
870
+ - Every generated function called `Jamdb.Oracle.query/3` on the value `Jamdb.Oracle.start_link/1`
871
+ returns. That is a `DBConnection` **pool**, and `query/3` sends a `{:sql_query, ...}`
872
+ `GenServer` call only a raw connection process answers, so the first call raised
873
+ `FunctionClauseError`. The backend's own `@spec` already said `DBConnection.conn()`. Queries now
874
+ execute through `DBConnection.execute/3`.
875
+ - `DBConnection.execute/3` returns `{:ok, query, result}`, so every result match gained the
876
+ middle element.
877
+ - **`RETURNING ... INTO` returns rows column-wise** — one single-element list per OUT parameter.
878
+ `INSERT ... RETURNING id, name INTO :2, :3` yields `%{rows: [[1], ["Alice"]]}`, not
879
+ `[[1, "Alice"]]`, so the old `[row | _]` match bound only the first column and destructured it
880
+ across every field. A plain `SELECT` is row-wise, so only the `RETURNING` path transposes.
881
+ - jamdb returns an Oracle `NUMBER` as an Elixir **float** whatever its scale — `1.0` for an
882
+ integer key, `99.99` for a `NUMBER(10,2)` — while the manifest declares those columns
883
+ `integer()` and `Decimal.t()`. `Decimal.equal?/2` rejects a float outright, which is how this
884
+ surfaced; the integer case was quieter and merely wrong. Numeric columns are now converted to
885
+ the type the struct declares.
886
+
887
+ `elixir-postgrex` and `elixir-ecto` were unaffected throughout. The CI step is restored, and
888
+ `elixir-jamdb-oracle` now passes end-to-end. (#223)
889
+
890
+ - **A composite value containing a double quote came back truncated, with every field after it
891
+ shifted.** PostgreSQL's `record_out` escapes a literal `"` inside a quoted composite field by
892
+ *doubling* it (`ROW('he said "hi"', 'back\slash')` renders as `("he said ""hi""","back\\slash")`),
893
+ but every composite text parser scythe emits recognized only the backslash spelling. On a doubled
894
+ quote each one took the first `"` for the field's closing quote — truncating that field's value and
895
+ then resynchronizing on the wrong character, so unrelated later fields silently received wrong
896
+ values. Fixed in all nine emitted parsers (`java-jdbc`, `java-r2dbc`, `kotlin-jdbc`, `kotlin-r2dbc`,
897
+ `kotlin-exposed`, `python-psycopg3`, `typescript-pg`, `typescript-postgres`, `typescript-kysely`);
898
+ the five JVM ones shipped with the defect, the rest inherited it from `java_jdbc.rs` as the model.
899
+ Covered by `composite_text_escaping_regression.rs`, which runs the emitted python parser against
900
+ the exact text PostgreSQL 16 produced. (#204)
901
+
902
+ - **A nullable composite column decoded to the driver's raw value while the generated type claimed
903
+ otherwise.** `python-psycopg3` and `python-asyncpg` declared `address: UserAddress | None` and the
904
+ three typescript backends declared the composite interface, but all five assigned the driver's raw
905
+ value straight through — a `str` for psycopg3, an `asyncpg.Record` for asyncpg, `undefined` fields
906
+ for the typescript drivers. psycopg3 and typescript now parse PostgreSQL's composite text form
907
+ through a generated `_from_text` / `parse{Name}`; asyncpg reads the `Record` it already decodes
908
+ through `_from_record`. A nullable enum column likewise now reads as `None if raw is None else T(raw)`
909
+ rather than calling the enum constructor on `None`. Verified live against PostgreSQL 16, which is
910
+ how the defect was found in the first place.
911
+
912
+ The remaining seven PostgreSQL backends are now fixed too, each according to what its driver
913
+ actually does — established by reading the vendored driver source rather than assuming:
914
+ `elixir-postgrex` and `elixir-ecto` get a `from_tuple` conversion, because Postgrex already
915
+ decodes a composite into a natively-typed positional tuple and never hands back text; `ruby-pg`,
916
+ `php-pdo`, `php-amphp`, `csharp-npgsql` and `go-pgx` get a text parser, because their drivers do
917
+ hand back `record_out` text. `csharp-npgsql` additionally sets `UnknownResultTypeList` for the
918
+ composite column, since Npgsql's native `MapComposite<T>` needs a registration the generated code
919
+ cannot perform on the caller's behalf; `go-pgx` is the same story for pgx's type map. PHP's parser
920
+ is emitted once per file as a shared class rather than copied into each composite. (#204)
921
+
922
+ All seven integration harnesses now select a composite column and assert on it — a present value,
923
+ a SQL NULL, a nullable enum, and a field containing `"` and `,`. That last case is the one that
924
+ matters: an assertion using only plain values passes identically against the pre-fix parser, which
925
+ is how the doubled-quote defect survived in nine backends. Confirmed falsifiable by reverting the
926
+ fix in `ruby-pg` and watching the new assertion catch it —
927
+ `expected "12 \"Main\", Apt 3", got "12 "`. (#204, #226)
928
+
929
+ - **The generated python composite parser did not type-check, and cast a NULL sub-field away.**
930
+ `_from_text` fed `_parse_composite_fields`' `str | None` tokens straight into fields declared
931
+ `str`, which pyrefly rejects — and PostgreSQL does permit a NULL sub-field, so the value really
932
+ can arrive. Silencing the checker with a cast would have traded a type error for a value that
933
+ lies at runtime, so the str-typed fields now route through a `_require_composite_field` guard that
934
+ raises naming the field that was NULL. asyncpg's `_from_record` also gained an `Any` annotation on
935
+ its `record` parameter, which pyrefly rejected outright as unannotated. (#204)
936
+
937
+ - **A composite whose field named another composite emitted the two definitions in the wrong order.**
938
+ The analyzer discovers composites breadth-first, so a type reached only through another composite's
939
+ field list landed *after* the type that references it. Languages whose declarations hoist never
940
+ noticed; python evaluates `@dataclass` annotations when the class body runs, so the generated module
941
+ raised `NameError` on import. Definitions are now emitted in dependency order. (#204)
942
+
943
+ - **Four integration projects had their generated output checked for freshness but never executed.**
944
+ `elixir-jamdb-oracle` and `ruby-oci8-oracle` now run in `integration-oracle`, `kotlin-jdbc-ext` and
945
+ `php-pdo-namespace` in `integration-pg`. Each already had a `test:*` Taskfile target and needed no
946
+ new infrastructure — only the missing workflow step. `php-pdo-snowflake` stays exempt, with its
947
+ reason corrected: `pdo_snowflake` ships as neither a PECL nor an apt package and must be built from
948
+ source against Snowflake's C driver, which is infrastructure work rather than a missing step. This
949
+ is the gap that let the csharp-snowflake parameter-binding bug survive from v0.6.0 to 0.14.0. (#118)
950
+
951
+ - **A semicolon inside a SQL comment broke every harness that executes the shared schema.** Each
952
+ generated harness runs `sql/<engine>/schema.sql` by splitting it into single statements on the
953
+ semicolon character, and that split is not comment-aware — so a semicolon inside a `--` comment
954
+ ended the fragment there and left the rest of the comment line to be sent as bare SQL.
955
+ `elixir-postgrex` failed with `ERROR 42601 syntax error at or near "this"`. Only elixir surfaced
956
+ it, because the postgres job fails fast and the harnesses ahead of it happen not to split that
957
+ schema. The comment is rewritten and a `schema_sql_comments_contain_no_semicolon` generator test
958
+ now enforces the fixture side of the contract; the naive splitting itself is tracked separately.
959
+
960
+ - **`ruby-oci8`'s teardown called a method that does not exist.** The generated harness ended with
961
+ `conn&.close`, but `OCI8` disconnects via `#logoff` — so the `ensure` block raised
962
+ `NoMethodError` and masked whatever the real failure had been.
963
+
964
+ - **Generated Ruby raised `LoadError` on Ruby 3.4+.** `bigdecimal` stopped shipping as a default gem
965
+ in Ruby 3.4.0, and `ruby-pg`, `ruby-mysql2` and `ruby-trilogy` emit `require "bigdecimal/util"`
966
+ whenever a query's generated code applies `.to_d` to a `decimal` column — so on 3.4 that `require`
967
+ failed unless something else in the bundle happened to depend on the gem. The generated `Gemfile`
968
+ for those three drivers now declares `bigdecimal` explicitly. `ruby-oci8` declares it too, for a
969
+ second and independent reason: ruby-oci8's own `lib/oci8/bindtype.rb` requires `bigdecimal` lazily
970
+ when it decodes an Oracle `NUMBER` column and does not declare that dependency in its gemspec, so
971
+ reading any numeric column raises `LoadError` regardless of what scythe emits. `ruby-sqlite3` and
972
+ `ruby-tiny-tds` need neither and are unaffected. CI pinned Ruby 3.3 — a version predating the
973
+ change — so it structurally could not observe any of this; the integration workflow now pins 3.4.
974
+
975
+ - **An enum reachable only through an array column generated with no variants.** The analyzer's
976
+ enum-discovery loop matched the bare `enum::x` neutral type, so a column typed `mood[]` — neutral
977
+ type `array<enum::mood>` — was never recognized as referencing `mood`. `scythe-codegen`, which
978
+ unwraps containers on its own, then found the type reachable but had no `EnumInfo` for it and fell
979
+ back to a stub with an empty variant list, emitting an enum declaration with no variants. (#165)
980
+
981
+ - **An explicit but empty `[sql.gen]` table silently generated a `rust-sqlx` target.** A legacy
982
+ `[sql.gen]` block naming none of `rust`/`python`/`typescript`/`go`/`kotlin` resolved to a default
983
+ `rust-sqlx` target rather than an error — the same silent-fallback shape #97 removed for an
984
+ *unresolvable* target, left open for a block that resolves to *nothing*. Omitting the `gen` key
985
+ entirely still defaults to `rust-sqlx`, which is documented and intended. (#165)
986
+
987
+ - **A `derive` backend option repeating a base derive produced code that would not compile.**
988
+ `SqlxBackend::derive_line` appended every `extra_derives` entry unconditionally, so naming `Debug`
989
+ (always in the base set) or `serde::Serialize` alongside `serde = true` emitted a duplicate derive
990
+ token — `E0119`, conflicting trait implementations, in the generated file. (#165)
991
+
992
+ - **A typo'd case name in a `[naming]` manifest overlay installed silently.** `apply_case` passes an
993
+ unrecognized case name through unchanged, which is safe for the compiled-in manifests but not for an
994
+ overlay, the one path a case name reaches it from outside. `struct_case = "PascalCse"` was accepted
995
+ and then emitted every affected identifier uncased. Overlays are now validated against the four real
996
+ case names. (#165)
997
+
998
+ - **`scythe lint <file>` ignored `[lint.sqruff]`.** Explicit-file mode built its sqruff linter with
999
+ `None` in place of the config's rule table, unconditionally — the same gap #206 closed for `fmt`,
1000
+ left open in `lint`. A `[lint.sqruff]` that config-mode `lint` rejects was silently accepted when
1001
+ the same config was paired with a file argument. (#206)
1002
+
1003
+ - **A `column = "table.col"` override that could only ever match a *parameter* was never flagged.**
1004
+ The unmatched-override preflight built its known-references set from columns alone, so a qualified
1005
+ override naming a real parameter reference but no column passed silently — as did a typo'd one,
1006
+ since neither could be distinguished from an override that simply never fires. `resolve::param_references`
1007
+ is now chained into the same set, feeding the existing diagnostic rather than adding a second. (#189)
1008
+
1009
+ - **`SC-PRV09`, `SC-PRV10`, `SC-PARSE01` and `SC-PARSE02` could not be configured, counted, or
1010
+ discovered.** All four were ad hoc `Error`-severity findings `scythe-cli` constructed directly at
1011
+ the point of failure (an unconstructable `[[sql.gen]]` target, a query file with zero recognized
1012
+ blocks, a query that fails to parse, a query that fails semantic analysis), never as registered
1013
+ `LintRule`s — so `[lint.rules]` and `[lint.categories]` had no effect on any of the four, and the
1014
+ documented "8 provenance rules" undercounted the 11 that actually exist by two. `SC-PRV09`
1015
+ (`gen-target-invalid`) and `SC-PRV10` (`empty-query-file`) now join `SC-PRV01`-`08`/`SC-PRV11` in
1016
+ `scythe_lint::provenance_registry`; `SC-PARSE01` (`unparseable-query`) and `SC-PARSE02`
1017
+ (`unanalyzable-query`) get a new `scythe_lint::parse_registry` and `RuleCategory::Parse`, since they
1018
+ fire from `check`, `lint`, and `audit` alike rather than a single check-time command. All four are
1019
+ zero-behavior `LintRule`s exactly like the rest of the provenance family: the finding itself is
1020
+ still built where the failure is detected, but its severity is now resolved from the registry
1021
+ instead of hardcoded. (#216)
1022
+
1023
+ - **A schema-qualified enum or composite generated two different names for the same type.** The
1024
+ declaration side spelled the type through `enum_type_name` / `composite_type_name`, which strip
1025
+ characters an identifier cannot hold; the reference side — the type as it appears in a column,
1026
+ parameter or composite-field annotation — called `to_pascal_case` directly. So
1027
+ `CREATE TYPE app.point` was declared as `AppPoint` and referred to as `App.point`, a `.` inside
1028
+ a type position that no target language parses, and the reference never matched the declaration
1029
+ it named. Both paths now share one helper. The same call also hardcoded PascalCase instead of
1030
+ honouring the manifest's `struct_case`; that half was latent only because all manifests currently
1031
+ set PascalCase, and is fixed alongside. Separately, the composite declaration itself inlined
1032
+ `to_pascal_case(&composite.sql_name)` in roughly sixty backend call sites rather than sharing one
1033
+ place, including five nested-composite reference sites that disagreed with their own declaration.
1034
+ (unfiled)
1035
+
1036
+ - **A composite reachable only as another composite's field was never emitted.** The analyzer
1037
+ collected composites by scanning selected columns and nested field types, and never looked inside
1038
+ a composite's own fields, so selecting a column whose type nests another composite produced code
1039
+ referring to a type that was never defined. Codegen gated emission on the same incomplete check,
1040
+ so collecting it in the analyzer alone would not have been enough. Both now walk the full
1041
+ reachability closure, with a visited set that also serves as the diamond and cycle guard. This
1042
+ was documented as a known gap when the JVM composite reader landed; it is now closed. (unfiled)
1043
+
1044
+ - **A qualified `column = "table.col"` type override was silently ignored for parameters outside
1045
+ `SELECT *`.** The per-parameter match key was built from a query-level table name that only ever
1046
+ exists for a single-table `SELECT *`, so on any explicit select list the override matched nothing
1047
+ and was dropped without a word — the parameter half of the defect whose column half was fixed
1048
+ earlier. Parameters bound by a direct `col op $N` comparison now carry their own owning relation,
1049
+ taken from the real table name rather than an alias. Parameters with no single owning column (an
1050
+ `IN` list, a `LIKE` pattern, a literal comparison) deliberately carry none and keep their previous
1051
+ behaviour rather than guessing. (#189)
1052
+
1053
+ - **Every JVM backend read a composite column through `getObject(col, T.class)`, which throws at
1054
+ runtime.** pgjdbc registers no type map for a user-defined composite, so `PSQLException:
1055
+ conversion to class T ... not supported` was raised the first time any generated JVM reader
1056
+ touched one — code that compiled and then failed on first use. Composites now read as text and
1057
+ parse through a generated `fromText` factory implementing PostgreSQL's composite text-form rules:
1058
+ an empty unquoted field is NULL, a field needing quoting is wrapped in `"` with `"` and `\`
1059
+ backslash-escaped inside, and a nested composite arrives quoted and recurses. Five assertions that
1060
+ pinned the broken `getObject` shape as correct were inverted. Still unhandled and documented
1061
+ rather than dropped: array-typed composite fields, per-field NULL into a primitive-typed field,
1062
+ and a composite reachable only as another composite's field, which the analyzer never collects.
1063
+ (unfiled)
1064
+
1065
+ - **`rust-tokio-postgres` could not bind or read a composite column at all.** The generated struct
1066
+ derived neither `ToSql` nor `FromSql`, so `row.get` and the bind path both failed to resolve.
1067
+ Composites now derive `postgres_types::ToSql`/`FromSql` with `#[postgres(name = "...")]`, since
1068
+ postgres-derive matches the Postgres type name exactly while scythe PascalCases the identifier.
1069
+ `postgres-types` is a transitive dependency of `tokio-postgres`, but its `derive` feature is not
1070
+ forwarded, so it is now declared directly in the integration scaffolding. (unfiled)
1071
+
1072
+ - **A `column = "table.col"` type override was a silent no-op unless the query was `SELECT *`.**
1073
+ Column resolution built one qualified name from a query-level source table populated only for a
1074
+ star expansion, so an explicit select list had nothing to qualify against. Columns now carry their
1075
+ own source relation — the real table name, not the alias — and `None` where there genuinely is
1076
+ one (a computed expression, literal, or function result). Two silent halves went with it: a
1077
+ combined `column` + `db_type` entry returned `false` the moment `column` missed instead of falling
1078
+ through to `db_type`, and an override matching nothing produced no diagnostic whatsoever. It is
1079
+ now a hard error before generation starts. A qualified override on a *parameter* is still inert
1080
+ outside `SELECT *`; that needs analyzer work and is tracked, not quietly half-fixed. (#189)
1081
+
1082
+ - **A schema-qualified table emitted a `.` inside its model struct name.** `SELECT * FROM
1083
+ app.widgets` produced `pub struct App.widget`, the same defect fixed for enums earlier. Row struct
1084
+ names are unaffected — `@name` is already restricted to ASCII identifier characters, verified
1085
+ rather than assumed. Separately, two different queries in one output file whose generated types
1086
+ collapse onto one identifier emitted two declarations of that name; collisions are now keyed by
1087
+ name *and* rendered body, so the identical-body case remains the intended dedupe. Composite struct
1088
+ names still carry the dot bug across 56 inlined call sites and are tracked separately. (#136)
1089
+
1090
+ - **`scythe migrate` passed a malformed annotation straight through and still reported success.** A
1091
+ wrong-case return-type keyword, a missing return type, or whitespace inside `sqlc.arg( name )`
1092
+ missed the strict pattern and was emitted unconverted. Malformed input is now reported, and the
1093
+ final output is scanned for residual `sqlc.arg(`/`sqlc.narg(`. (#152, partial)
1094
+
1095
+ - **`scythe lint` and `scythe audit` accepted an unknown `[[sql]] engine` and silently analyzed it as
1096
+ PostgreSQL.** `SqlDialect::from_str(&engine).unwrap_or(SqlDialect::PostgreSQL)` in both
1097
+ `lint_cmd.rs` (config mode and explicit-file mode, two separate call sites) and `audit.rs`
1098
+ (config mode) turned a typo like `mysql8` into a silent PostgreSQL run — wrong catalog parsing,
1099
+ wrong dialect-gated rule set, no diagnostic — while `scythe generate` already rejected the same
1100
+ config outright. A new `scythe_lint::parse_engine_dialect`, sharing one alias list with
1101
+ `audit --dialect`'s existing validation, now errors naming the offending value and the accepted
1102
+ aliases. (#165, item 3)
1103
+
1104
+ - **`scythe check` passed on stale output after a `[[sql.gen]]` option changed.** The provenance
1105
+ header fingerprinted the schema and the queries but not the options that decide what is generated
1106
+ from them, so switching `row_type` from `pydantic` to `msgspec`, or editing the contents of a
1107
+ manifest overlay, left the header byte-identical and `check` reported the artifact fresh. A sixth
1108
+ `options=` field now covers the target's resolved `[[sql.gen]]` options together with the *contents*
1109
+ of its manifest overlay, and `SC-PRV11` reports a mismatch as its own finding rather than folding
1110
+ into the existing header rules. A header written before this field existed is still read as
1111
+ complete — absence means "generated by an older scythe", not "drifted" — and a target with no
1112
+ options and no overlay produces bytes identical to the old five-field header. All 111 committed
1113
+ integration artifacts are regenerated to carry it. Fingerprinting uses FNV-1a rather than the
1114
+ `ahash` used elsewhere: ahash's "fixed" keys are regenerated per process from OS randomness, so it
1115
+ cannot produce a value that is stable across the write and the later verify. (#155)
1116
+
1117
+ - **Two queries selecting the same composite column emitted its model struct twice.** Enum
1118
+ definitions were already deduplicated when assembling an output file; the composite/model structs
1119
+ beside them were not, so a second query selecting the same composite produced a duplicate type
1120
+ declaration — a compile error in every target with a one-definition rule. Deduplicated on the
1121
+ rendered struct text, the same way enums already are, and not scoped to the JVM. (unfiled)
1122
+
1123
+ - **A schema-qualified enum emitted a `.` inside the generated type name, and two names colliding in
1124
+ one file went undetected.** `CREATE TYPE app.status AS ENUM (...)` carries its qualifier into
1125
+ `EnumInfo::sql_name`, and case conversion alone does not remove it, so `app.status` became
1126
+ `App.status` — `pub enum App.status`, a syntax error in every target that shares this path. Enum
1127
+ type names now go through the same `sanitize_for_identifier` the variant labels already used.
1128
+ Separately, `to_pascal_case` returned the empty string when every `_`-delimited part was empty (a
1129
+ bare `"_"`, or the underscore run a symbols-only label sanitizes to), emitting a type with no name;
1130
+ it now falls back to its sanitized input, matching what `to_camel_case` already did. Two generated
1131
+ *type* names that collapse onto one identifier — two enums, or an enum and the query's own row type
1132
+ — are now rejected with `DuplicateAlias` instead of emitting two declarations of the same name.
1133
+ (#136)
1134
+
1135
+ - **Parameters were bound by declaration order rather than by where they appear in the SQL, so a
1136
+ repeated or out-of-order placeholder bound the wrong argument.** `java-jdbc`, `kotlin-jdbc`,
1137
+ `kotlin-exposed` and `php-amphp` emitted one `?` per *declared* parameter and then set them
1138
+ `1..n` in declaration order. A query writing `$2` before `$1` therefore bound the caller's first
1139
+ argument to the second slot — silently wrong results, no error — and a query repeating `$1` emitted
1140
+ fewer binds than the rewritten SQL contained, which the driver rejects at execute time. Placeholder
1141
+ rewriting now returns the sequence of parameter positions it actually emitted, and each backend
1142
+ binds from that sequence. `preprocess_oracle_sql` and `preprocess_mssql_sql` were also collapsing
1143
+ `:N` / `@pN` to a bare `?` before parsing, discarding which N each referred to; they now emit `$N`,
1144
+ which sqlparser's `OracleDialect` and `MsSqlDialect` both tokenize as `Token::Placeholder` through
1145
+ the default `supports_dollar_placeholder` impl. (#149)
1146
+
1147
+ - **SQL-text cleanup and placeholder rewriting were dialect-blind, corrupting MySQL and MSSQL
1148
+ identifiers.** The comment stripper and placeholder rewriter knew only PostgreSQL quoting, so a
1149
+ MySQL backtick-quoted identifier containing `--` had the rest of the query deleted, a MySQL `#`
1150
+ line comment was left in place, and an MSSQL `[bracketed]` identifier containing a comment marker
1151
+ was truncated the same way. `SqlDialect` is now threaded through the whole SQL-text pipeline, and
1152
+ backtick and bracket spans are recognised as quoted regions alongside PostgreSQL's. Bare `?` under
1153
+ PostgreSQL was previously governed by a heuristic — rewrite `?` only if the query contains no
1154
+ `$<digit>` anywhere — which corrupted a zero-parameter query using the JSONB `?` operator; the
1155
+ decision is now made from the dialect instead of from a scan of the text. This is the last of
1156
+ #186's items; the JSONB `?` operator, dollar-quoted strings and `NOT LIKE` were fixed earlier.
1157
+ (#186)
1158
+
1159
+ - **`:one` and `:opt` rendered identical code on 53 backends, so one of the two contracts was always
1160
+ silently wrong.** `:one` means "exactly one row, error if absent"; `:opt` means "zero or one". Every
1161
+ affected backend matched `QueryCommand::One | QueryCommand::Opt` in a single arm, so whichever
1162
+ behaviour that arm happened to implement won for both. Each language now gets an error path built
1163
+ from its own idiom — a raised `ScytheNoRowsError` / `RecordNotFound` / `RecordNotFoundException`, a
1164
+ thrown `NoSuchElementException` or `InvalidOperationException`, `Mono.error` on the reactive
1165
+ backends, the driver's own `ErrNoRows` in Go, `{:error, :not_found}` in Elixir, and `Err` in Rust —
1166
+ while `:opt` keeps its existing shape everywhere. Ruby `.rbs` signatures and PHP return-type
1167
+ declarations were narrowed to match, so signatures no longer over-promise nullability. (#197)
1168
+
1169
+ The direction was not uniform, and the earlier census recorded it wrongly for 10 of the 53. On the
1170
+ `go-*` and `elixir-*` backends `:one` was already correct — `sql.ErrNoRows` propagates through
1171
+ `row.Scan`, and Elixir already returned `{:error, :not_found}` — and it was `:opt` that wrongly
1172
+ errored on a legitimately absent row. `go-godror` folded the permissive way while its three Go
1173
+ siblings did not, so even same-family behaviour was not safe to assume.
1174
+
1175
+ - **`python-snowflake` declared `:execrows` as `-> int` while returning `cur.rowcount`, which the
1176
+ DB-API types `int | None`.** Narrowed at the call site rather than widening the annotation:
1177
+ psycopg, aiosqlite, aiomysql and oracledb all type `rowcount` as plain `int`, so snowflake was the
1178
+ lone outlier and widening would have spread the imprecision to seven backends. (unfiled)
1179
+
1180
+ - **`typescript-postgres` could not bind a composite-typed parameter.** postgres.js serialises only
1181
+ values it recognises, and a plain object standing for a PostgreSQL composite is not one, so the
1182
+ generated tagged template failed to type-check. Composite parameters are now expanded to
1183
+ `ROW(${field}, ...)::type_name` — one binding per scalar field, recursing through nested composites
1184
+ — instead of being interpolated whole. (unfiled)
1185
+
1186
+ - **A `rust-sqlx` `:grouped` query selecting a non-identifier column produced code that could not
1187
+ compile.** The grouped path reads its flat rows through the untyped `sqlx::query!` macro, whose row
1188
+ field names come from sqlx's own expansion of the raw column names rather than from this backend's
1189
+ `sanitize_field_names` convention. sqlx's `parse_ident` requires the driver-reported name to be a
1190
+ valid Rust identifier and otherwise fails macro expansion outright, so a quoted `"my col"` was a
1191
+ hard compile error, not a silent mismatch. Such columns now get an explicit `AS "field_name"` so the
1192
+ macro sees a name scythe chose. Note this is a different mechanism from the `#[sqlx(rename)]`
1193
+ attribute added earlier for `FromRow`: both `query!` and `query_as!` build their row type directly
1194
+ and never consult `FromRow`, so that attribute has no effect on either macro path. (unfiled)
1195
+
1196
+ - **The same `rust-sqlx` defect was live on the plain `:one`/`:many`/`:opt` path, and its enum
1197
+ aliasing emitted a stray backslash into the SQL.** `generate_query_fn` selected a non-identifier
1198
+ column unaliased, so `parse_ident` failed macro expansion there too; and a column whose name is a
1199
+ valid identifier but differs in shape from this backend's `field_name` (case, or
1200
+ `sanitize_field_names` reshaping) failed against a struct-literal field spelled differently, since
1201
+ `quote_query_as` builds `#out_ty { #ident: #var_name }` from the driver-reported name. Separately,
1202
+ `rewrite_sql_for_enums` hand-wrote its alias as `\"…\"` in Rust source — a literal backslash and
1203
+ quote — and then passed it through `escape_rust_string`, which escaped both again, so the SQL sqlx
1204
+ saw at compile time contained a backslash nobody asked for. Both paths now share one
1205
+ `rewrite_sql_for_row_columns`, which aliases whenever `field_name` differs from the column name or
1206
+ an enum override applies, writes the alias as a single plain `"…"`, and is escaped exactly once.
1207
+ (unfiled)
1208
+
1209
+ - **`check` printed "All queries valid." for a query file it had not checked at all.** A file whose
1210
+ annotations were never recognised — a mistyped `--name:`, or every statement commented out — yields
1211
+ zero query blocks, and `has_unannotated_sql` deliberately ignores it, so the run reported success
1212
+ having examined nothing. A non-empty file that produces no query blocks is now an `SC-PRV10` error
1213
+ naming the file. A genuinely empty or whitespace-only file is still accepted: there is nothing there
1214
+ that could have been misrecognised. (unfiled)
1215
+
1216
+ - **`VARBINARY(MAX)` resolved to the invalid neutral type `varbinary(max)`, which no manifest maps.**
1217
+ SQL Server's unbounded binary type parses to `DataType::Varbinary(Some(BinaryLength::Max))`, for
1218
+ which `normalize_data_type` had no arm at all, so it fell to the catch-all that stringifies through
1219
+ `Display`. `strip_precision` only strips a trailing `(<digits>)`, so `max` survived, never matched
1220
+ the bare `varbinary` arm, and the column resolved to a type name rather than `bytes`. The sibling
1221
+ `VARCHAR(MAX)`/`NVARCHAR(MAX)` spellings were already correct — their arms route
1222
+ `CharacterLength::Max` through a `_ => "text"` fallback — and all ten mssql-capable manifests
1223
+ already mapped `bytes`, so no manifest changed. `BINARY` needs no equivalent arm: sqlparser types
1224
+ it `Option<u64>`, making `BINARY(MAX)` unrepresentable. (unfiled)
1225
+
1226
+ - **A literal `%` in SQL broke every `%`-paramstyle Python driver at execute time.** `WHERE name LIKE
1227
+ 'a%'` reaches psycopg3 and aiomysql as a format string, and `%'` is not a valid placeholder, so the
1228
+ driver raised before the statement was ever sent. The `%` is now doubled — but only for a query that
1229
+ actually binds parameters. psycopg3 and PyMySQL run `%`-formatting exclusively from
1230
+ `execute(query, params)`; a parameterless `execute(query)` passes the string through untouched, so
1231
+ doubling it there would have replaced a driver-side error with a silently wrong `LIKE 'a%%'` that
1232
+ matches nothing. `python-snowflake` additionally emits
1233
+ `snowflake.connector.paramstyle = "qmark"` to match the `?` it generates — previously the only
1234
+ `paramstyle` assignment in the tree was a hand-written compensation inside the integration harness,
1235
+ so every consumer of the generated module got none. (#201)
1236
+ - **`python-aiomysql` rewrote a `?` inside a SQL string literal.** A blind `.replace('?', "%s")` ran
1237
+ *after* the literal-aware `rewrite_pg_placeholders`, so `WHERE note = 'really?'` became
1238
+ `'really%s'` — a silent wrong answer, not an error. GH #153 was closed with this half unfixed.
1239
+ - **`scythe lint <file>` ran no scythe rules at all.** Explicit-file mode built a sqruff linter and
1240
+ never constructed a `LintEngine`, so every `SC-*` rule was skipped — `scythe lint queries.sql`
1241
+ silently checked far less than `scythe lint` with the same config, and the code said so in a
1242
+ comment. It now builds a catalog from the config's first `[[sql]]` block and runs the native rules
1243
+ with suppressions honoured, falling back to sqruff-only when there is genuinely no schema to build
1244
+ from. `scythe fmt <file>` likewise dropped `[lint.sqruff]` entirely, honouring only the dialect
1245
+ half of #206.
1246
+ - **`scythe check` green-lit an `output` path that `scythe generate` refuses.** `check` never applied
1247
+ #207's containment rule, so a config could pass the check and then fail the thing the check exists
1248
+ to predict. (#206, #207)
1249
+ - **A `CREATE VIEW` with an explicit column list got no types at all.** The branch handling
1250
+ `CREATE VIEW v (a, b) AS SELECT …` never ran the analyzer: `sql_type` fell back to the literal
1251
+ string `"unknown"` and `nullable` was hardcoded `true`, so the same view declared with and without
1252
+ a column list produced different — and wrong — columns. It now analyzes the body and overlays the
1253
+ declared names. A declared list whose arity disagrees with the body is now an error rather than
1254
+ silently mismatched output, mirroring how a `WITH t(a,b) AS …` alias list is already handled.
1255
+ - **`ALTER TABLE … RENAME TO` on an unknown table did nothing, silently.** Every sibling operation —
1256
+ `AddColumn`, `DropColumn`, `RenameColumn`, `AlterColumn`, `AddConstraint` — errors on a missing
1257
+ table; `RenameTable` alone fell through with no `else`, so a typo'd migration was indistinguishable
1258
+ from a correct one. It now follows the same precedent.
1259
+ - **`json_each` and friends were typed `string` in select-list position.** They return `SETOF record`,
1260
+ not text. The neutral type vocabulary cannot name an anonymous record — `composite::{name}` needs a
1261
+ catalog entry and the `json_nested` machinery assumes the value on the wire is JSON text, which a
1262
+ native composite is not — so they now resolve to `unknown`, following the precedent
1263
+ `json_populate_record` already set, rather than to a confidently wrong scalar.
1264
+ `json_array_elements`/`jsonb_array_elements` previously hit the unknown-function error path and now
1265
+ resolve to `json`, matching what the FROM-position handling already assigned.
1266
+ - **`rust-sqlx`'s `:opt` output never compiled.** The return type said `{Struct}` while the body's
1267
+ `has_row_struct` guard excluded `Opt`, so it emitted the anonymous-record `sqlx::query!` instead of
1268
+ `sqlx::query_as!` — the declared type and the produced type disagreed on every `:opt` query the
1269
+ backend has ever generated. `:opt` now returns `Option<{Struct}>` and fetches with
1270
+ `.fetch_optional`, which is what the command means. `rust-tiberius`'s `:opt` likewise stopped
1271
+ emitting `.expect("expected one row")`, a panic in generated code on exactly the absent row `:opt`
1272
+ exists to handle. (#197)
1273
+ - **`rust-sqlx` mapped a mangled field back to the wrong column.** The backend derives
1274
+ `sqlx::FromRow`, which looks a column up *by the Rust field name*, and #215's
1275
+ `sanitize_field_names` renames any non-identifier column — so `my col` became a field `my_col` that
1276
+ `FromRow` then searched for under that name and could not find. A compile fix bought at the cost of
1277
+ a runtime one. Fields whose generated name differs from the SQL column now carry
1278
+ `#[sqlx(rename = "…")]`. The other Rust backends were checked and are unaffected: tokio-postgres
1279
+ and tiberius look up by the raw SQL name, sibyl reads positionally.
1280
+ - **`typescript-duckdb` typed a `bytes` column as something the driver never returns.** The manifest
1281
+ declared `Uint8Array`; `@duckdb/node-api` hands a BLOB back as `DuckDBBlobValue`. Verified against
1282
+ the published package rather than inferred — 1.5.5-r.4 ships
1283
+ `class DuckDBBlobValue { readonly bytes: Uint8Array }` and lists it in the `DuckDBValue` union. The
1284
+ read direction had no test at all, which is why this survived. Note the manifest has no read/bind
1285
+ split, so the bind-position type changed too: construct one with the driver's
1286
+ `blobValue(Uint8Array | string)`.
1287
+ - **The tool-validation schemas contained no container or user-defined type.** The ~20 PostgreSQL
1288
+ backend tests that compile generated code with a real compiler — the strongest gate in the project
1289
+ — never asked one to accept an array, an enum, an array of enums, a composite, a `uuid` or a
1290
+ `jsonb` column, which is why the JSDoc and JVM enum defects above survived. The schemas now carry
1291
+ all of them, and every added column is selected by the query each test runs; a widened schema with
1292
+ an unwidened query would have added columns no generated file reaches. MySQL gains an inline
1293
+ `ENUM(...)` column for the same reason. (#146)
1294
+ - **The two `SC-INS09` live tests raced each other.** Both trusted `CREATE EXTENSION IF NOT EXISTS`
1295
+ to tell them where an extension landed; they now verify against `pg_extension`/`pg_namespace`. (#144)
1296
+ - **`SC-N02` (`table-naming`) could not see a CamelCase table name.** The catalog stores tables under
1297
+ a lowercased lookup key, so by the time the rule read the name every table looked snake_case and
1298
+ `CREATE TABLE "UserProfile"` passed. `Table` now keeps the DDL's own spelling in `raw_name`
1299
+ alongside the lookup key, and the rule reads that. The existing test asserted the miss verbatim —
1300
+ it guarded the bug rather than against it — and is inverted here. (#145)
1301
+ - **A placeholder inside a `LIKE` pattern or an `IS NULL` operand was dropped from the generated
1302
+ signature.** `WHERE name LIKE '%' || $1 || '%'` and `WHERE $1 IS NULL` both bind a parameter, but
1303
+ the analyzer only collected one from a `LIKE` whose pattern was a bare literal and never descended
1304
+ into `IS NULL` / `IS NOT NULL` at all — so the generated function took fewer arguments than the
1305
+ statement needs. Placeholder positions are now memoised by source span, which keeps a parameter
1306
+ repeated across several expressions from being counted more than once. (#171)
1307
+ - **`go-pgx` emitted a static import block that omitted imports its own types needed.** A query
1308
+ selecting a `json` or `uuid` column produced `*json.RawMessage` and `uuid.UUID` with neither import,
1309
+ so the file did not compile; the generated header conceded as much by advising `goimports -w .`.
1310
+ #100 fixed the opposite direction — an import emitted but unused. Imports are now derived from the
1311
+ types actually emitted, via the `[imports.rules]` table every Go manifest already declared and
1312
+ nothing read. `go-pgx` consequently passes the torture gate and has been removed from the
1313
+ expected-failure allowlist. The PHP casts likewise come from the manifest instead of a hardcoded
1314
+ table that contradicted it. (#198)
1315
+ - **A JVM enum whose SQL spelling was not the uppercase of its variant threw on every read.** Binding
1316
+ emitted `.getValue()` / `.value` — the SQL value — while reading emitted
1317
+ `valueOf(rs.getString(col).toUpperCase())` — the variant *name*. For a value like `in-active` with
1318
+ variant `IN_ACTIVE`, `toUpperCase()` yields `IN-ACTIVE`, which `valueOf` rejects with
1319
+ `IllegalArgumentException`; case-folding is not the same operation as sanitising. The generated
1320
+ `value`/`getValue()` accessor that makes this exact was emitted and consulted by no reader. Reads
1321
+ now match on the declared SQL value. The existing tests asserted the `toUpperCase()` spelling
1322
+ verbatim, so they pinned the defect and changed with the fix. (#213)
1323
+ - **Every `javascript-*` file containing an enum failed `tsc --checkJs`.** The generated
1324
+ `/** @type {const} */` sat on the declaration, where it is `TS2304: Cannot find name 'const'`. The
1325
+ valid position is the initializer expression — `= /** @type {const} */ ({…})` — which also narrows
1326
+ to literal types as intended. The same spelling existed as three byte-identical copies across
1327
+ `typescript-pg`, `typescript-postgres` and `typescript-mysql2`; they now share one
1328
+ `generate_js_enum_def`, so the next fix here lands once instead of three times.
1329
+ - **A non-identifier column name was spliced raw into a JSDoc `@property`.** `@property {string} my
1330
+ col` is `TS1003: Identifier expected`, and unlike the TypeScript emit path the JSDoc row typedef
1331
+ cannot mangle the name — a generated row type is cast onto the driver's rows, so its key must stay
1332
+ the column's own spelling. The typedef now switches to JSDoc's quoted type-literal form
1333
+ (`@typedef {{ "my col": string }}`) when any key is not a bare name, and keeps the `@property` form
1334
+ otherwise. `@param` mangling is unaffected and remains correct: a binding is a JavaScript
1335
+ parameter, which has no quoted form.
1336
+ - **`javascript-better-sqlite3`'s `:batch` path never type-checked.** `db.transaction((items) => …)`
1337
+ with an unannotated parameter makes TypeScript infer `never` from better-sqlite3's variadic
1338
+ signature, giving TS2488 and TS2345. The TypeScript emit path annotates it as `(items: T[])`; the
1339
+ js_mode path now carries the equivalent inline `@param`. This was invisible until the enum fix
1340
+ above stopped `tsc` short-circuiting on an earlier error.
1341
+ - **`typescript-postgres`'s single-parameter `:batch` rewrote `${field}` inside a SQL string
1342
+ literal.** A blind `String::replace` matched the tail of an escaped `\${field}`. #219 covered the
1343
+ `$N` form only.
1344
+ - **A `:grouped` query's `.rbs` described a class the `.rb` file never defines.** The RBS producer
1345
+ resolved the flat column list where the Ruby producer splits parent from child, so the signature
1346
+ declared one class with neither the `children` reader nor the child class `Data.define` actually
1347
+ emits — `steep check` against a correct `.rb` failed on the signature, not the code. The RBS path
1348
+ now performs the same split. `RbsQueryInfo` carries the child columns in their own field; an
1349
+ earlier revision smuggled them through a sentinel in `ResolvedColumn.full_type`, which is the shape
1350
+ that leaked `__unknown_col__` into user-visible output in #173. (#203)
1351
+ - **Eight `.rbs` files were rejected outright by `rbs parse`.** The Ruby backend emitted
1352
+ `library "bigdecimal"` ahead of any signature referencing `BigDecimal`, but `library` is Steepfile
1353
+ and CLI syntax, not an RBS declaration, so the parser failed at the first token with "cannot start
1354
+ a declaration". A signature naming `BigDecimal` needs no directive at all. The `.rb` side keeps its
1355
+ `require "bigdecimal/util"`, which is genuinely needed for `.to_d`.
1356
+ - `elixir-exqlite` releases its prepared statement on every exit path, not just the success one;
1357
+ `elixir-tds` types `bytes` and `time`/`time_tz` parameters instead of falling through to `:string`;
1358
+ and a `:grouped` query with no parent columns no longer emits `defstruct [, :children]`, which is
1359
+ not valid Elixir. (#202)
1360
+ - **A column named `my col`, `with-dash` or `2fa` reached a field declaration verbatim in every
1361
+ language but TypeScript.** `pub my col: String`, `my col: str`, `My col string`, `String my col` —
1362
+ none of them parse, and no gate caught it because the torture schema has no such column. #215 fixed
1363
+ this for TypeScript by quoting (`"my col": string`, `row["my col"]`), which is the right answer
1364
+ *there* and only there: a generated TypeScript row type is cast onto the driver's rows, so its key
1365
+ has to stay the column's own spelling. The other nine targets have no quoted form for a field and
1366
+ never read a column back by the generated name — they use the position or the raw SQL name
1367
+ (`rs.getString("my col")`) — so their 85 manifests now set `[naming] sanitize_field_names`, and
1368
+ `field_name` replaces the characters an identifier cannot hold. A leading digit takes a `col_`
1369
+ prefix rather than a bare `_`, because `to_pascal_case` drops a leading underscore and go-pgx and
1370
+ the C# backends case the field name a second time, which handed the digit straight back. The SQL
1371
+ text is untouched. (#215)
1372
+ - **`IDENTITY` preprocessing ate the whitespace after the keyword and rewrote its case.** The catalog
1373
+ strips `IDENTITY(seed, step)` before parsing; when the keyword was *not* followed by a clause, the
1374
+ branch that put it back pushed a literal uppercase `"IDENTITY"` and resumed from the position it had
1375
+ already advanced past the whitespace, so `GENERATED ALWAYS AS IDENTITY PRIMARY KEY` became
1376
+ `IDENTITYPRIMARY KEY` and a column named `identity` became `IDENTITYTEXT NOT NULL`. The original
1377
+ characters are now copied through unchanged. Thanks to @fzlzjerry. (#154)
1378
+ - **An unsupported nested `json_agg` degraded to a single JSON object even where the driver could
1379
+ describe the array.** The degradation pass rewrote every column referencing a nested struct the
1380
+ backend did not implement to plain `json`. A distinct `json_array` scalar marker now carries "one
1381
+ JSON document whose top level is an array", and `typescript-pg`, `python-asyncpg`, `elixir-postgrex`
1382
+ and `php-pdo` opt into it by declaring it in their manifests. It is deliberately not the `array<json>`
1383
+ container, which means a SQL `json[]` column and can select a typed array reader: `csharp-npgsql`
1384
+ would have declared `List<string>` while reading through the untyped `GetValue` accessor. Backends
1385
+ that declare no `json_array` mapping keep the plain-`json` fallback unchanged. Thanks to @fzlzjerry.
1386
+ - **A parameter named after a column like `my col`, `with-dash` or `2fa` was emitted verbatim into a
1387
+ binding.** `export async function findWeird(client: PoolClient, my col: string)` does not parse, and
1388
+ neither does its equivalent in the other nine target languages. #215 fixed the two positions that
1389
+ have a quoted form — the declared property key and the property read — and left this one pinned as a
1390
+ known gap, because a binding has no quoted form anywhere and mangling is a cross-language naming
1391
+ decision. `scythe_backend::naming::param_name` now makes it: characters an identifier cannot hold
1392
+ become `_`, and a leading digit takes a `_` prefix. Only parameters are mangled. A column's field
1393
+ name is a contract with whatever the driver returns, so it keeps its raw spelling and its quoting;
1394
+ the SQL text is untouched, and any collision the mangling introduces (`my col` against a real
1395
+ `my_col`) is reported by the existing duplicate-field check rather than silently resolved. (#215)
1396
+ - **`python-psycopg3` bound a reserved-word parameter to a name it never passed.** It is the one
1397
+ backend that binds by name rather than position, and it derived the two halves of that contract
1398
+ separately — the `execute` dict from the resolved param's `field_name`, the `%(...)s` placeholder
1399
+ from a second `to_snake_case` of the raw SQL name. The spellings matched until anything else touched
1400
+ `field_name`: a param named `class` became `class_` in the signature and the dict while the SQL still
1401
+ asked for `%(class)s`, so every call raised `query parameter missing: class` at execute time. Nothing
1402
+ earlier could catch it — the module imports, type-checks and passes the generated-code gate, which
1403
+ compiles generated code and never runs it. Both halves now come from the resolved param, the way
1404
+ `typescript-postgres` already did it. `crates/scythe-codegen/tests/python_named_placeholder_regression.rs`
1405
+ asserts the invariant (every placeholder is a dict key) rather than the single keyword that exposed it.
1406
+ - **A column named after a TypeScript keyword produced a file that would not parse.** Every generated
1407
+ TypeScript query function takes its parameter names from the columns they are compared against, so a
1408
+ `class` column emitted `export async function q(client: PoolClient, class: string)` — `TS1390`, and
1409
+ the syntax error stopped `tsc` before it type-checked anything else in the file. The seventeen
1410
+ TypeScript manifests now declare `[naming] reserved_bindings`, consulted by a new
1411
+ `scythe_backend::naming::param_name`, which mangles a keyword to `class_` where it lands in a
1412
+ binding. Deliberately *not* the existing `[naming] reserved` list: that is applied to columns too,
1413
+ and a generated TypeScript row type is cast straight onto the driver's rows
1414
+ (`client.query<FindByClassRow>(...)`), so renaming the key would have described an object `pg` never
1415
+ returns — a compile error traded for a silent wrong answer. `class` therefore stays `class` in the
1416
+ row type and in `row.class`, both of which are legal TypeScript. Five of the six TypeScript entries
1417
+ in `scripts/torture-expected-failures.txt` are gone; `typescript-postgres` still fails, on a
1418
+ composite-typed parameter postgres.js cannot bind, which was invisible behind the syntax error.
1419
+ (#180)
1420
+ - `scripts/check-generated-backends.py` ran `ruby -c` over `queries.rbs`. The script globs every file
1421
+ in a backend's output directory and picked the syntax checker by *backend*, but RBS is a signature
1422
+ language, not Ruby, so it choked on `ACTIVE: String` and reported a `ruby-pg` failure that no change
1423
+ to the generated code could ever have cleared. The entry sat in
1424
+ `scripts/torture-expected-failures.txt` blamed on unescaped SQL, which it never had anything to do
1425
+ with. Syntax checkers are now selected by file extension first, since a file's language is a property
1426
+ of the file and not of the backend that emitted it — the distinction
1427
+ `scripts/check-generated-syntax.sh` already made, now with one derivation instead of two. `ruby-pg`
1428
+ builds clean against the torture schema and is out of the allowlist.
1429
+ - Every remaining reason in `scripts/torture-expected-failures.txt` was re-derived from the compiler's
1430
+ actual output rather than carried forward. All five non-TypeScript entries had been grouped under
1431
+ "unescaped quoted identifier (#179)", written mid-rollout and wrong for every one of them by the time
1432
+ 740cc99 finished the escaping layer: the three Rust projects fail because their scaffolding declares
1433
+ neither `serde_json` nor `uuid`, `go-pgx` fails on a static import block that omits what its own
1434
+ emitted types reference (#198), and `ruby-pg` was the harness bug above. A gate that checks only
1435
+ pass/fail cannot check *why*, so the file now carries an instruction to re-derive before editing.
1436
+ - `SC-SEC01` (`dangerous-function`) missed set-returning functions called in `FROM` position
1437
+ (`FROM dblink(...)`, `FROM pg_ls_dir('/etc')`, `FROM openrowset(...)`) — the idiomatic way these
1438
+ particular functions are written — because the matcher only inspected `Expr::Function` nodes and
1439
+ `pre_visit_relation` was a no-op. It now also matches the relation name. (#138)
1440
+ - `SC-SEC06` (`weak-hash-in-auth`) missed salted and wrapped hash arguments: `md5(password || salt)`
1441
+ and `md5(lower(password))` produced no finding, only the bare `md5(password)` form did.
1442
+ `extract_sensitive_column` now recurses through `BinaryOp`, `Nested`, `Function` and `Cast`. (#138)
1443
+ - `SC-A03` (`or-in-join-condition`) only fired when the `OR` in a JOIN's `ON` clause was
1444
+ unparenthesised, and only inspected the ON clause's root expression instead of descending it — so
1445
+ `ON (a OR b)` and `ON x AND (a OR b)`, both real occurrences of the same antipattern, produced no
1446
+ finding. It now unwraps parentheses and descends through `AND` conjuncts, counting each top-level
1447
+ disjunction once. (#145)
1448
+ - `engine.rs`'s cross-query duplicate-name check (`SC-C03`) hardcoded `Severity::Error` regardless of
1449
+ `[lint.rules]`, so `"SC-C03" = "warn"` had no effect, and it fired even when `DuplicateQueryNames`
1450
+ was not registered in the calling registry at all. It now resolves severity through the registry,
1451
+ same as every other rule, and produces no finding when the rule isn't active. (#137)
1452
+ - `SC-A02` (`implicit-type-coercion`) implements no check and is off by default with no way to ever
1453
+ produce a finding if enabled; its description now says so explicitly, matching `SC-C01`. (#137)
1454
+ - Inline suppression comments (`-- scythe-audit: ignore[...]`) were keyed by source line, so two
1455
+ statements sharing one physical line (`DROP TABLE a; DROP TABLE b;`) resolved to the same key and a
1456
+ suppression meant only for the first silently covered the second too. `SuppressionSet` is now keyed
1457
+ by 0-based statement index instead — **callers must pass a statement index, not a computed source
1458
+ line**. The module doc's claim that a blank line between an annotation and its statement still
1459
+ attaches was also wrong; the code discarded it then and still does, so the doc was corrected instead
1460
+ of the (intentional) behavior. (#140)
1461
+ - A user-supplied `[[audit.rule]]`'s declared `cwe` array had no way to reach a caller through
1462
+ `LintRule` — only `MatcherRule`'s private `RuleSpec` held it, so every consumer fell back to
1463
+ scanning `description` for `CWE-\d+` text and a declared `cwe` with no such text in its description
1464
+ was silently dropped. `LintRule` gained a `cwe()` method (default: empty; `MatcherRule` prefers the
1465
+ declared `cwe`, falling back to the description scan only when it's empty). (#140)
1466
+ - `MatcherRule::check_query`'s dialect gate (`spec.dialects`) was invisible from outside — a rule
1467
+ scoped to Postgres just silently returned nothing on every other engine, indistinguishable from a
1468
+ rule that ran and found nothing. `LintRule` gained an `is_applicable_to(dialect)` method (default:
1469
+ every dialect; `MatcherRule` exposes its `spec.dialects` gate) so a caller can count and report
1470
+ skipped, not-applicable rules instead of an engine's `scythe audit` reading as a clean pass when
1471
+ most rules never ran. (#167)
1472
+ - `[lint.sqruff] enabled` was declared and never read: `enabled = false` did not disable sqruff.
1473
+ It now does. Separately, `[lint.sqruff.rules]` wrote any non-`"off"` value into sqruff's `rules`
1474
+ key, which sqruff treats as an *allowlist* — so `"LT02" = "warn"` silently disabled every other
1475
+ sqruff rule, the opposite of what it reads like and of what the docs claimed. sqruff has no
1476
+ per-rule severity at all, so only `"off"` can be honoured and any other value is now rejected with
1477
+ a message naming the offending key. An unknown rule code, previously swallowed, is also reported.
1478
+ (#113, #114)
1479
+ - A rejected `[lint.sqruff]` table aborted the entire lint run and discarded every scythe-native
1480
+ finding along with it, because the sqruff call sits ahead of the rule engine in the per-file loop.
1481
+ A single typo could silently switch off the security rules, `SC-SEC07` PII detection included. The
1482
+ configuration is now validated once per `[[sql]]` block before any query file is read, so a config
1483
+ mistake is reported as one and the blast radius is visible rather than silent. Note validation
1484
+ lints a trivial statement: sqruff checks rule codes when a string is linted, not when the linter is
1485
+ built.
1486
+ - `SqruffConfig::default()` returned `enabled: false`, the opposite of an absent `[lint.sqruff]`
1487
+ table, because `#[serde(default)]` only applies to absent TOML input and not to a derived `Default`.
1488
+ No call site hit it, but `enabled` only recently became load-bearing.
1489
+ - Ruby `.rbs` signatures were emitted from a hardcoded scalar table rather than the backend manifest,
1490
+ so they could disagree with the `.rb` code generated beside them. `ruby-oci8` declared
1491
+ `created_at: Date` while the query bound a `Time`. Every RBS scalar now comes from the manifest.
1492
+ Regenerate to pick this up. (#106)
1493
+ - A `[[sql.gen]]` entry missing its required `output` key produced a generic untagged-enum
1494
+ deserialization error that named neither the field nor the block. The error now names both, and
1495
+ unknown keys in a `[[sql]]` block are rejected rather than silently ignored. (#116)
1496
+ - Every PHP manifest declared its `array` container as `array<{T}>`, which reached the generated file
1497
+ in a native type position where PHP has no generics: `public array<string> $tags` is a parse error.
1498
+ Two routes hit it — a PostgreSQL array column, and an `= ANY(...)` parameter, which the analyzer
1499
+ synthesises as `array<T>` in *every* dialect, so the broken type landed in function signatures even
1500
+ on engines with no array type of their own. (#200)
1501
+ - All five JVM backends resolved a column's reader from a table maintained in parallel with the
1502
+ manifest, and every type outside that table fell through to an untyped accessor — `rs.getObject(col)`
1503
+ on the JDBC family, `row.get(col, Object.class)` / `Any::class.java` on the R2DBC pair. The declared
1504
+ field type came from the manifest, nothing compared the two, and the result did not compile:
1505
+ `incompatible types: Object cannot be converted to WidgetAddress`. Readers now derive from the
1506
+ declared type itself, so the two cannot drift. Three defects fell out of the same tables: the R2DBC
1507
+ arms matched `LocalDate` before `LocalDateTime` and read every datetime column as a date;
1508
+ `kotlin-exposed` called `wasNull()` nowhere, so a SQL NULL in a nullable `Int?` arrived as `0`; and
1509
+ all three JDBC backends read a nullable enum as `valueOf(getString(col).toUpperCase())`, an NPE on
1510
+ exactly the value the column exists to hold. (#191, #192, #213, #214)
1511
+ - `java-r2dbc` emitted top-level records, a top-level enum and bare static methods into one
1512
+ compilation unit, and closed its `:grouped` row buffer with `});` while `.flatMap(` was still open.
1513
+ Neither had ever compiled. (#191)
1514
+ - TypeScript emitted raw column names into positions that require an identifier. `ts_property_key`
1515
+ existed and was correct but only the row-struct emitters used it, so batch-params interface members,
1516
+ per-item binds, dot-access row reads and oracledb object-literal keys spliced the name verbatim —
1517
+ `first name: string;`, `[item.first name]`, and `row['it's']` closing its own quote. Property
1518
+ positions are now quoted; a scalar *parameter* named after a non-identifier column is still broken,
1519
+ because quoting is not available in a binding position, and is pinned by a failing-when-fixed test.
1520
+ (#215)
1521
+ - `row_type = "zod"` derived its types from a table maintained beside the manifest, so the two
1522
+ disagreed on four of six columns in the same query: `active` was `number` under `interface` and
1523
+ `boolean` under `z.infer`, `price` `number` vs `string`, `created_at` `string` vs `Date`. Zod types
1524
+ now derive from the resolved TypeScript type, so `z.infer` equals the manifest type by construction.
1525
+ Enum variants also went through raw `to_pascal_case` and had their values spliced unescaped —
1526
+ `In-active: "in-active",` is not a valid key. (#216)
1527
+ - `typescript-duckdb` imported `Connection`, which `@duckdb/node-api` does not export, and called
1528
+ `stmt.run(args)`, which takes no arguments. Every file this backend has ever produced failed to
1529
+ compile. Values now bind through `stmt.bind()`. (#217)
1530
+ - `typescript-oracledb` bound the driver result to `const result` inside the block where the grouped
1531
+ fold declares its own (`Cannot redeclare block-scoped variable`), uppercased row keys
1532
+ unconditionally so a quoted lower-case column read as `undefined` with no compile error, and ignored
1533
+ `row_type = "zod"` entirely — there was a test certifying that no-op. (#218)
1534
+ - The postgres.js `:batch` path rewrote `$N` with a raw string replace while every other command path
1535
+ used the literal-aware rewriter, so `VALUES ($1, $2, 'lit $1 $2 end')` turned an inert SQL string
1536
+ literal into two extra live bindings. It compiled, ran, and stored the wrong text. (#219)
1537
+ - Six JSON functions were split across arms whose behaviour followed from which arm they landed in
1538
+ rather than from their semantics: `jsonb_agg` lost the nested-struct inference `json_agg` got,
1539
+ `to_json`/`to_jsonb` over a whole-row reference returned flat `json` and were hardcoded non-nullable
1540
+ despite being strict, and `json_strip_nulls` was likewise fixed non-nullable.
1541
+ - The JSON function table is now derived from `pg_proc.proisstrict` and measured behaviour rather than
1542
+ assumption. Four functions had no arm at all, so legal PostgreSQL failed with a hard
1543
+ `unknown function` error: `array_to_json`, `json_object`/`jsonb_object`, `jsonb_set`/`jsonb_insert`
1544
+ and `jsonb_pretty`. `jsonb_set_lax` reports `proisstrict = f` but still returns NULL for a NULL
1545
+ target or path — only its replacement argument is exempt — so it gets its own arm. `json_typeof`,
1546
+ `jsonb_typeof` and `json_array_length`/`jsonb_array_length` were unconditionally nullable where the
1547
+ database is strict, and now follow their argument.
1548
+ - A bare MySQL `?` placeholder used as a plain arithmetic operand in the SELECT list (`SELECT age + ?
1549
+ AS x FROM users`) was dropped entirely: `infer_expr_type`'s `Expr::Value` arm only resolved a
1550
+ placeholder's position via `parse_placeholder`, which parses `$N` but returns `None` for `?`, so the
1551
+ occurrence never reached `resolve_placeholder_position` and the generated function signature was
1552
+ missing an argument. Separately, `analyze_select` visited `WHERE`/`HAVING` before the projection, so
1553
+ a `?` textually first in the SELECT list was numbered *after* one appearing later in `WHERE` —
1554
+ `SELECT CAST(? AS CHAR) AS tag, name FROM users WHERE age = ?` bound the WHERE placeholder first.
1555
+ Projection is now analyzed before `WHERE`/`HAVING`, and the `Expr::Value` placeholder arm resolves
1556
+ through `resolve_placeholder_position` for both `$N` and `?`. (#170)
1557
+ - **`java-r2dbc` and `kotlin-r2dbc` threw `IllegalArgumentException` on any null argument.** R2DBC's
1558
+ `Statement.bind(index, value)` rejects null outright — `bindNull(index, Class<?>)` is the only way
1559
+ to send SQL NULL — and both backends emitted `bind` for every parameter regardless of nullability,
1560
+ so a nullable parameter failed at the bind call rather than reaching the database. Ordinary
1561
+ nullable parameters now route through a generated `bindNullable` helper; a nullable enum gets an
1562
+ inline null check instead, because its bind expression calls `.getValue()`/`.value` on the field
1563
+ and would throw before any helper could test it. Both PostgreSQL harnesses gained a call that
1564
+ passes a real null, which is what makes the regression catchable: reverting the fix now fails them
1565
+ with the driver's own "value must not be null". The `Batch` bind sites are untouched and still have
1566
+ a separate pre-existing gap — a batch enum parameter binds the raw enum object with no
1567
+ `.getValue()`/`.value` call.
1568
+ - **`java-r2dbc` and `kotlin-r2dbc`'s `:batch` bind sites never got either fix above.** They bound
1569
+ every parameter unconditionally (the same `IllegalArgumentException` on a null batch argument that
1570
+ ordinary bind sites had) and, for an enum, bound the raw Java/Kotlin enum object instead of its SQL
1571
+ spelling (the same "no codec for a user enum type" failure). Both backends' bind-site logic is now
1572
+ shared between the ordinary and `:batch` code paths through a `write_r2dbc_bind_for`/`r2dbc_bind_expr_for`
1573
+ pair that takes an explicit receiver expression (a loop variable or a batch-params record/data-class
1574
+ accessor) instead of always reading the parameter's own field. The PostgreSQL enum placeholder cast
1575
+ (`add_pg_enum_casts`) already reached `:batch` SQL before this fix, since it operates on the one `sql`
1576
+ local shared by every command shape — that part needed a test, not a fix. Covered by new backend unit
1577
+ tests only: the PostgreSQL fixture schema both harnesses build from (`integration_tests/sql/pg/queries/`)
1578
+ has no `:batch` query at all, so neither harness can yet exercise this path end to end — still an
1579
+ unfalsifiable gate at the integration level until a `:batch` fixture query exists.
1580
+ - **A misspelled annotation (`@nullible`, `@optionall`, `@nonull`, ...) was captured and silently
1581
+ discarded.** Any `-- @<name> <value>` line scythe does not natively recognise is deliberately kept
1582
+ as an opaque `CustomAnnotation` — that escape hatch is how consumers layer their own annotation
1583
+ vocabulary (`@http`, `@http_auth`, ...) on top of scythe — but nothing ever inspected it, so a
1584
+ typo'd override behaved identically to one with no override at all while `scythe generate`,
1585
+ `scythe check` and `scythe lint` all reported success. `CustomAnnotation` now carries a
1586
+ `suggested_keyword` when the unrecognised name is within edit distance 2 of a known keyword
1587
+ (`name`, `returns`, `param`, `nullable`, `nonnull`, `json`, `deprecated`, `group_by`, `optional`),
1588
+ for a caller to turn into a warning. Left as a signal rather than a hard parse error: rejecting
1589
+ every unrecognised annotation would break the same consumer-defined vocabulary the escape hatch
1590
+ exists for. (#152)
1591
+ - **`scythe migrate` reported every `sqlc.arg`/`sqlc.narg` name as "renamed" while discarding it.**
1592
+ It emitted `-- @param {name}`, which `scythe_core::parser` stores as a docs-only `ParamDoc` that
1593
+ the analyzer never reads for naming — only the positional `-- @param $N {name}` form becomes a
1594
+ `PositionalParamDoc` and actually renames the generated parameter. A migrated
1595
+ `sqlc.arg(needle)`/`sqlc.arg(mailbox)` query silently fell back to inferred or `pN` parameter
1596
+ names on the very next `scythe generate`, even though `migrate` printed "2 param(s) renamed".
1597
+ `migrate` now emits the positional form, with the same sequential numbering it already assigns to
1598
+ the placeholder. (#152)
1599
+ - **Two SQL values of the same enum could collide on the generated variant name and `scythe generate`
1600
+ wrote both anyway.** `'gpt-3.5-turbo'` and `'gpt_3_5_turbo'` both sanitize and case-convert to
1601
+ `Gpt35Turbo` under `enum_variant_case = "PascalCase"` (Rust, C#, Go, TypeScript); nothing compared
1602
+ the rendered variant names before `generate_enum_defs_via_backend` handed them to a backend, so the
1603
+ file came out with `pub enum Model { Gpt35Turbo, Gpt35Turbo, }` — `E0428` under a real `rustc`, a
1604
+ redeclaration in every other target — while the command exited 0. A new `resolve::check_enum_variant_collisions`
1605
+ runs once per enum, the variant counterpart of the existing enum/query-type-name check, and rejects
1606
+ the query with `DUPLICATE_ALIAS` before any backend renders it. (#136)
1607
+
1608
+ - **Four more PostgreSQL manifests lost a nested aggregate's list-ness on degrade, the same way
1609
+ `java-jdbc.toml`'s `json = "String"` collapses `json_agg` down to one opaque string.**
1610
+ `elixir-ecto`, `php-amphp`, `typescript-kysely` and `typescript-postgres` now declare `json_array`
1611
+ for an array-shaped `json_agg`/`row_to_json` result their backend does not construct into a typed
1612
+ struct, each verified against the exact decode path an already-declared sibling manifest relies on:
1613
+ `elixir-postgrex`'s Postgrex/Jason pipeline for `elixir-ecto` (both run raw SQL through the same
1614
+ Postgrex binary protocol, verified live against PostgreSQL 16); `php-pdo`'s generated
1615
+ `json_decode($value, true)` for `php-amphp` (the same call, independently emitted); `typescript-pg`'s
1616
+ `pg` auto-parsing for `typescript-kysely`'s PostgreSQL dialect (documented as running over `pg`
1617
+ unchanged) and for `typescript-postgres`'s `postgres.js` driver (which parses `json`/`jsonb` the same
1618
+ way). Scope, precisely: `catalog_has_nested_aggregates` only infers a nested aggregate for the
1619
+ PostgreSQL dialect on a postgresql-family engine — Redshift and DuckDB are excluded by name — so only
1620
+ the 19 postgresql-engine manifests can reach this path at all, and after this change 4 of them build a
1621
+ real struct, 8 keep the array shape, and 7 still collapse to plain `json` (`csharp-npgsql`,
1622
+ `java-jdbc`, `java-r2dbc`, `kotlin-exposed`, `kotlin-jdbc`, `kotlin-r2dbc`, `ruby-pg`). Those 7 map
1623
+ `json` to a raw string with no driver- or codegen-level array decoding to point to, so a distinct
1624
+ `json_array` marker would carry no real information over `json` itself; `ruby-pg` is the one worth
1625
+ revisiting, since the `pg` gem can decode JSON but nothing in the generated code configures it. `json_nested` (a typed struct, not just array-shape) requires a
1626
+ backend-side decoder — `generate_nested_struct_def` — that a manifest alone cannot add, so it stays at
1627
+ its existing four (`rust-sqlx`, `rust-tokio-postgres`, `go-pgx`, `python-psycopg3`). (#147)
1628
+
1629
+ - **A `json_agg`/`row_to_json` column degraded to plain `json` (or `json_array`) on the 15 of 19
1630
+ PostgreSQL backends that do not implement `generate_nested_struct_def`, and nothing said so.**
1631
+ `degrade_unsupported_nested_structs` rewrote the column's neutral type and `scythe generate` exited 0,
1632
+ so a user asking for a structured nested row from, say, `java-jdbc` (`json = "String"`, read back via
1633
+ `rs.getString`) got an opaque string with no indication a struct was ever requested. The function now
1634
+ also returns one `NestedStructDegradation` per rewritten column — the SQL column name, the struct that
1635
+ could not be built, the fallback type it got instead, and the backend — threaded onto
1636
+ `GeneratedCode::degraded_nested_structs`. This is a library-side signal only: `scythe-cli` still needs
1637
+ to turn each entry into a reported finding (`scythe-codegen` cannot install a subscriber or depend on
1638
+ `scythe-cli`/`scythe-lint`). Not a hard error by default — failing every degrading backend outright
1639
+ would break working setups. (#147)
1640
+
1641
+ - **A bare `?` placeholder or literal `NULL` projected with no `CAST`/comparison/`COALESCE` to borrow a
1642
+ type from reached `analyze()`'s `Ok` result typed `neutral_type: "unknown"`, then surfaced two layers
1643
+ down as the backend's `INTERNAL_ERROR: unknown neutral type: unknown`** — the part of #170 the
1644
+ counting/ordering fix (c288fce1) left open. `analyze()` now rejects the shape with `TYPE_MISMATCH`,
1645
+ naming the query and column and suggesting an explicit `CAST`. The rejection is origin-based, not a
1646
+ blanket check on `neutral_type == "unknown"`: it only fires on a column whose projected expression is
1647
+ itself a bare placeholder/`NULL`, so a UNION arm's `NULL` that a sibling arm resolves, and a
1648
+ `jsonb_each`/`json_each` record column (legitimately `"unknown"` — PostgreSQL's `record` pseudo-type
1649
+ has no neutral-type representation), are both unaffected. (#170)
1650
+
1651
+ - **A UNION with both arms projecting a bare `NULL`, or a bare `NULL`/placeholder projected out of a
1652
+ derived table or CTE, still reached codegen as `INTERNAL_ERROR: unknown neutral type: unknown`
1653
+ instead of the clean `TYPE_MISMATCH` above.** Two places stripped the `untyped_literal` taint before
1654
+ `analyze()`'s final check ever saw it: a UNION arm's widened column was rebuilt with
1655
+ `..Default::default()`, always dropping to `false` regardless of whether either side actually
1656
+ resolved a type; and a derived table's or CTE's output columns were folded back into scope through a
1657
+ constructor that hardcoded `untyped_literal: false`, resetting the flag the moment a column crossed a
1658
+ subquery boundary. The UNION case now survives the taint only when *both* arms are untyped — either
1659
+ side supplying a real type still clears it, so a `NULL` arm a sibling resolves is unaffected — and
1660
+ `ScopeColumn` now carries the flag from an already-analyzed output column through a derived-table/CTE
1661
+ boundary via a new `from_analyzed_column` constructor, while a genuine catalog column or a function's
1662
+ synthetic result (`jsonb_each` included) is untouched and stays untainted no matter how many subquery
1663
+ or UNION layers it passes through. (#170)
1664
+
1665
+ - **The Java and Kotlin integration-test generators had no way to notice their per-engine harness
1666
+ branches drifting apart.** `java.java.jinja` and `kotlin.kt.jinja` duplicate a whole test program
1667
+ per SQL engine, and nothing compared what one branch tests against another — the redshift branches
1668
+ quietly ended up with fewer than half the postgresql branch's test functions. A new parity gate
1669
+ (`tests/engine_test_parity.rs`) now fails the build when an engine branch is missing a test
1670
+ function the postgresql branch of the same template has, unless it is named in the new
1671
+ `test-parity-exemptions.txt` ratcheting allowlist with a reason; the allowlist also fails on stale
1672
+ entries, so it can only shrink. Separately, `oracle/schema_full.sql` and
1673
+ `redshift/schema_pg_compat.sql` are runtime-only schema variants that harness templates apply
1674
+ independently of the (possibly different) file `scythe.toml` generated queries from — safe only as
1675
+ long as both files agree on table/column shape, which nothing checked; a new
1676
+ `tests/schema_variant_consistency.rs` now checks it. (#196, #195)
1677
+
1678
+ - **Two queries in one `[[sql]]` block whose `@name` values differed only in case could render the
1679
+ same function name into one file, and `generate` exited 0.** `CreateAPIKey` and `CreateApiKey` both
1680
+ `snake_case` to `create_api_key`; `check_file_level_type_name_collisions` already caught this shape
1681
+ for row/model structs and enums but never compared query function names, and `assemble_body` has no
1682
+ dedup pass at all for `query_fn` (unlike the struct/enum lists, it pushes every result's function
1683
+ unconditionally), so the collision always reached the output file as two function definitions. The
1684
+ check now also compares `fn_name` across every query destined for the same file. (#136)
1685
+
1686
+ - **`scythe generate` silently produced different bytes for the same input depending on whether
1687
+ `rustfmt` happened to be on `PATH`, and said nothing either way.** `format_rust_code_if_possible`
1688
+ piped `rustfmt`'s `stderr` to `/dev/null` and fell back to the unformatted code on a failed spawn,
1689
+ a non-zero exit, or a broken pipe, all indistinguishably. A missing `rustfmt` is now reported as a
1690
+ warning (and still never fails the run — a missing toolchain says nothing about whether the
1691
+ generated code is correct); `rustfmt` spawning and then rejecting the input is reported with its
1692
+ own stderr and, since Rust has no other tool-based validator, now counts as a `--validate-output`
1693
+ finding the same way every other backend's real-compiler check already does. (#167)
1694
+ - **A misspelled annotation still reported success — nothing consumed the `suggested_keyword` signal
1695
+ #152 added to `CustomAnnotation`.** A typo like `@nullible` parsed clean, analyzed clean, and
1696
+ `scythe generate`/`check`/`lint` all exited 0 while the nullability override it named silently
1697
+ never took effect. New rule `SC-PARSE03` (`misspelled-annotation`) fires when
1698
+ `suggested_keyword` is set, naming both the annotation as written and the suggested keyword (e.g.
1699
+ `@nullible` → did you mean `@nullable`?). `Warn` by default, not `Error`: the same escape hatch
1700
+ the signal rides on is a deliberate extension point with legitimate shipping usage (`@http`,
1701
+ `@http_auth`), and `suggested_keyword` is a heuristic, not proof the annotation is wrong. Lives in
1702
+ `default_registry` rather than `parse_registry` (unlike `SC-PARSE01`/`SC-PARSE02`): it has a real,
1703
+ already-analyzed `LintContext` to inspect, so it needs no additional `scythe check` wiring beyond
1704
+ registration. The default registry now holds 59 built-in rules, up from 58. (#152, #167)
1705
+ - **`scythe migrate` parsed sqlc's top-level `plugins:` array and each `gen.<lang>.package` field
1706
+ and discarded both with no diagnostic.** Neither has a `scythe.toml` equivalent — scythe has no
1707
+ wasm/process plugin system to receive `plugins:`, and no backend supports overriding the
1708
+ generated-code package/module name (every scythe Go file hardcodes `package queries`) — so there
1709
+ is no config key `migrate` could fill in for either. Both are now a `warning:` on stderr naming
1710
+ what was dropped, rather than silence. Left as warnings, not `invalid_config` errors like an
1711
+ unsupported `gen.<lang>` target: a hard error on the mere presence of `plugins:` would fail
1712
+ ordinary, fully-convertible v2 configs that declare it only to satisfy sqlc's own plugin
1713
+ resolution alongside an otherwise-unremarkable `gen.go` block. (#152)
1714
+ - **`scythe-backend`'s type tests ran against a stale private copy of the manifests, not what
1715
+ scythe actually ships.** `crates/scythe-backend/test-manifests/{rust-sqlx,rust-tokio-postgres}.toml`
1716
+ had drifted from `crates/scythe-codegen/manifests/`: the private copies were missing
1717
+ `json_nested`, `sanitize_field_names` and the ~50-entry `reserved` keyword list entirely, and the
1718
+ tokio-postgres copy declared `range = "String"` where the shipped manifest declares
1719
+ `PgRange<{T}>`. Worse, a test asserted that stale `"String"` value directly, so it wasn't merely
1720
+ blind to drift — it actively pinned the bug, and would have broken the moment someone pointed it
1721
+ at the real file. `4ef83676` had already proven `PgRange<{T}>` correct by compiling the emitted
1722
+ wrapper with `rustc`. The private copies are deleted; both `types.rs` and `manifest.rs` tests now
1723
+ `include_str!` the manifests `scythe-codegen` ships, and assertions cover `reserved`,
1724
+ `sanitize_field_names`, `json_nested` and the corrected `range` value. (#157)
1725
+
1726
+ - **`scythe-conformance` never checked that a fixture's `expected.query.columns` matched what the
1727
+ analyzer actually produced for `query_sql`.** The four nullability assertions only ever iterate
1728
+ `analyzed.columns`, so a declared column absent from that list — a rename, a dropped `SELECT`
1729
+ item, a typo — was never fed into any of them: not a failure, not a skip, just silently never
1730
+ examined, even though every row still named it. `crate::runner::evaluate_fixture` now rejects a
1731
+ declared column the analyzer produced no match for, via a new
1732
+ `RunnerError::DeclaredColumnNotAnalyzed`. (#160)
1733
+
1734
+ - **A typo in a live-fixture's `live` block, a run, a row expectation, or an `engine_expectations`
1735
+ entry parsed clean and silently dropped the whole thing.** `LiveBlock`, `Run`, `RowExpectation`
1736
+ and `EngineExpectation` had no `#[serde(deny_unknown_fields)]`, and `null_together` /
1737
+ `engine_expectations` are `#[serde(default)]`, so a misspelled key evaporated instead of failing
1738
+ to parse. All four now reject unknown fields. (#160)
1739
+
1740
+ - **`DIVERGENCES.toml`'s `engine` field was a bare, unvalidated `String`.** A typo'd engine name
1741
+ (e.g. `"postgres"` instead of `"postgresql"`) loaded successfully and then matched no `Verdict`,
1742
+ forever, with no diagnostic — the entry would sit in the registry looking active while
1743
+ suppressing nothing. `DivergenceEntry::engine` is now typed as `Engine`, so an unrecognized
1744
+ engine name fails to deserialize instead. (#160)
1745
+
1746
+ - **The three unit tests in `scythe-conformance/src/executors/mssql.rs` ran in no CI job at all.**
1747
+ `ci.yml`'s `test` job runs `cargo test --workspace` with this crate's default (empty) feature
1748
+ set, which never compiles the `mssql`-gated module; `nullability-conformance.yml`'s mssql job
1749
+ passes `--test live`, which restricts `cargo test` to that one integration binary and excludes
1750
+ lib unit tests. `ci.yml` now runs `cargo test -p scythe-conformance --features mssql --lib` as
1751
+ its own step, on every push and pull request. (#160)
1752
+
1753
+ ### Changed
1754
+
1755
+ - **Six of the surviving `range` mappings named a type their driver does not produce, and are
1756
+ corrected; a seventh is removed.** Verified by running each real client against a live PostgreSQL
1757
+ instance rather than by reading the manifests. `csharp-npgsql` said `string`, but `GetString`
1758
+ throws `InvalidCastException` — now `NpgsqlTypes.NpgsqlRange<{T}>`. `go-pgx` said `string`, but
1759
+ pgx v5 refuses to scan a range into `*string` at all — now `pgtype.Range[{T}]`. Both Elixir
1760
+ manifests said `String.t()` where Postgrex returns `%Postgrex.Range{}` and rejects a plain string
1761
+ as a bind parameter. Both Python manifests said `tuple[{T}, {T}]`, and neither driver returns a
1762
+ tuple; they now name `asyncpg.Range[{T}]` and `psycopg.types.range.Range[{T}]` respectively,
1763
+ which are genuinely different classes, so the family spelling legitimately diverges.
1764
+ `rust-tokio-postgres` has no usable mapping — `postgres-types` excludes every range OID from
1765
+ `FromSql for String` and ships no range decoder — so its declaration is removed and recorded as a
1766
+ capability exception that fails the gate if anyone re-adds one without justification. Any query
1767
+ selecting a range column on these backends generated code that did not work; it now does, but the
1768
+ host type it names has changed. (#190)
1769
+
1770
+ - **The `range` container is now declared only on PostgreSQL manifests — 84 declarations become 19.**
1771
+ `range` was mapped in 84 of 102 manifests in seven mutually incompatible spellings, and nothing
1772
+ asserted anything about it. Presence tracked no engine capability in either direction: it was
1773
+ declared for MySQL, MariaDB, SQLite, MSSQL, Oracle, DuckDB and Redshift, none of which has a
1774
+ PostgreSQL-style range column type, and omitted from manifests whose siblings declared it. The
1775
+ spellings contradicted each other inside single language families and, in two cases, inside one
1776
+ file — `python-asyncpg` said `tuple[{T}, {T}]` while `python-asyncpg.redshift` said `str`;
1777
+ `elixir-postgrex` said `string()`, which is not the Elixir typespec for a binary at all. Dropping
1778
+ the key on an engine with no range type is a degradation only in the sense that a query can no
1779
+ longer silently resolve `range<T>` to a wrong host type there — it now falls through the unknown-
1780
+ container path like any other unmapped container. `range_container_consistency.rs` gates presence
1781
+ against engine and spelling against each family's own `string` scalar, in both directions. (#190)
1782
+ - **`scythe fmt --check` exits 2 rather than 1 when files need formatting.** #212 reserves exit 1 for
1783
+ operational failure — an unreadable file, an invalid config — and a distinct code for "the thing
1784
+ you asked about is not satisfied", which is what `lint` and `check` already do. `fmt --check` used
1785
+ a plain error for both, so a CI step could not tell a formatting difference from a broken run.
1786
+ Scripts branching on exit 1 from `fmt --check` need updating.
1787
+ - **Breaking (`elixir-ecto`): the backend emits Ecto instead of a Postgrex clone.** Generated
1788
+ functions take a `repo` rather than a `conn`, specs change from `Postgrex.conn()` to
1789
+ `Ecto.Repo.t()`, queries run through `Ecto.Adapters.SQL.query(repo, sql, args, [])`, and `:batch`
1790
+ uses `repo.transaction/1` with `repo.rollback/1`. Struct definitions also move to top level instead
1791
+ of nesting under `Scythe.Queries.*`. A backend named after Ecto that generated raw Postgrex calls
1792
+ was misnamed rather than merely limited. Every caller of a generated `elixir-ecto` function must
1793
+ now pass a repo module. (#202)
1794
+ - The PHP backends now render a type twice: the native position (property, parameter, return) keeps
1795
+ the bare `array` PHP's syntax requires, and `@var`/`@param` docblocks get `array<T>` back. A bare
1796
+ `array` is `array<mixed, mixed>` to PHPStan, so the fix that made the output parse cost every array
1797
+ column and every `= ANY(...)` parameter its element type at level 9. Manifests gained an optional
1798
+ `[types.docblock_containers]` table, which falls back per container name to `[types.containers]`;
1799
+ only the nine `php-*.toml` manifests declare it, and every other language's output is byte-identical.
1800
+ Measured on the torture schema at PHPStan level 9: 15 findings to 9 (php-pdo), 24 to 18 (php-amphp),
1801
+ all six removed being `missingType.iterableValue`.
1802
+ - Dependency pins for `integration_tests/**` are managed by Renovate against the jinja templates in
1803
+ `tools/integration-test-generator/templates/`, which is where they actually live. Dependabot cannot
1804
+ target generated files, so its PRs against them were dead on arrival. (#115)
1805
+ - `snowflake-jdbc` is unified on 4.0.2 across both JVM templates, which previously disagreed.
1806
+ - **The JVM backends have a real array reader, and array columns are `List<T>` again.** An earlier
1807
+ revision of this release degraded the JVM manifests to declare array columns as `String`, because
1808
+ no JVM backend could read one and `int[]`/`bool[]` additionally rendered `java.util.List<int>`,
1809
+ which is not valid Java. That entry said the degradation was not the destination; the reader now
1810
+ exists, so `array` maps to a boxed `List<T>` and the `String` fallback is gone. Regenerated JVM
1811
+ output changes shape for every array column. (#192)
1812
+ - `scythe lint` and `scythe fmt` build one sqruff linter per `[[sql]]` block instead of one per file.
1813
+ Construction compiles the dialect's lexer, so a run over N files paid N+1 constructions where one
1814
+ suffices; measured on 200 single-query files in one block, `scythe lint` goes from 0.547s to 0.047s.
1815
+ Construction is also validation, which moves an invalid `[lint.sqruff]` table from "error against
1816
+ whichever file was read first" to an error about the config itself. (#130)
1817
+
1818
+ ### Removed
1819
+
1820
+ - **Breaking (`scythe-codegen`)**: removed the public `generate_from_catalog` stub. It ignored its
1821
+ argument and always returned `Ok(GeneratedCode::default())`, so a caller could not distinguish
1822
+ "nothing to generate" from "this function does nothing" — reporting success while doing nothing is
1823
+ worse than not existing. It had no caller besides its own tautological test, which asserted the
1824
+ stub's behavior matched the stub's behavior and could never fail. If catalog-level codegen is
1825
+ implemented later it should land as a real implementation, not a reserved name. (#132)
1826
+ - **Breaking (`scythe-backend`)**: removed `BackendRenderer`, its jinja fixtures, and the
1827
+ `BackendError::TemplateError` variant, along with the crate's `minijinja` dependency. Code
1828
+ generation is done by the per-language emitters in `scythe-codegen`; the template renderer was a
1829
+ parallel mechanism with no production caller, so it read as a supported extension point that did
1830
+ not exist. Breaking only for a caller matching directly on that error variant.
1831
+ - Four `r2dbc` manifests for engines the r2dbc backends never accepted. They were unreachable.
1832
+ - **Breaking (`scythe-lint`)**: removed the free functions `sqruff_adapter::validate_config`,
1833
+ `lint_sql`, `lint_and_fix_sql` and `format_sql`. Each built a `SqruffLinter` per call, and building
1834
+ one compiles the dialect's lexer — the cost that dominated `scythe lint` until #130 hoisted
1835
+ construction out of the per-file loop. Leaving them in left a second way to do the same thing where
1836
+ the obvious use (a loop over files) silently reintroduced that cost. Use `SqruffLinter::for_linting`
1837
+ (returns `None` for `[lint.sqruff] enabled = false`) with `lint` / `lint_and_fix`, or
1838
+ `SqruffLinter::new` with `format`, building one linter per run instead of per file;
1839
+ `validate_config` is `for_linting` with the linter discarded, so keep the linter. None were
1840
+ re-exported from the crate root, so only a caller naming `scythe_lint::sqruff_adapter::` directly is
1841
+ affected. (#130)
1842
+
1843
+ ## [0.14.0] - 2026-08-09
1844
+
1845
+ This release checks scythe's output against something other than scythe. Nullability inference is
1846
+ measured against what live database engines actually return across all six of them. Generated files
1847
+ now record the schema they came from, and `scythe check` can diff your DDL against the database the
1848
+ code will actually run against. A Snowflake backend that had never executed anywhere runs in CI for
1849
+ the first time.
1850
+
1851
+ Three of those checks found real bugs the model-only tests could not: Oracle returns NULL for an
1852
+ empty string literal, `typescript-duckdb` had been reading rows positionally while indexing them by
1853
+ name, and `typescript-oracledb` cast nullable columns to their non-null type. All three are fixed
1854
+ below.
1855
+
1856
+ **Upgrading**: `scythe check` now exits `2` for findings and `1` for operational failures, so a CI
1857
+ script keying on `1` needs updating. Unrecognized options on any `[[sql.gen]]` target — not just
1858
+ TypeScript — are now an error rather than silently ignored. Identifiers derived from names with
1859
+ consecutive capitals change spelling (`CreateAPIKeyRow` becomes `CreateApiKeyRow`). And every
1860
+ generated file gains a provenance header, so the first regeneration after upgrading touches every
1861
+ artifact. See **Changed** for the full list.
1862
+
1863
+ ### Added
1864
+
1865
+ - A per-target manifest override: `manifest = "..."` on a `[[sql.gen]]` target names a **partial**
1866
+ manifest merged over the backend's compiled-in one, so a project can retarget a few type mappings,
1867
+ naming fields or import rules without vendoring a whole manifest. The path resolves against the
1868
+ directory containing `scythe.toml` — the same rule every other path in the config follows since
1869
+ 0.13.0 — so generated output does not depend on where the command was run. The override is keyed
1870
+ per target rather than per backend name: `rust-sqlx` covers five engines and `java-jdbc` nine,
1871
+ each with its own type mappings, and a `[[sql.gen]]` target inherits its engine from the enclosing
1872
+ `[[sql]]` block, so two targets naming the same backend under different engines each get their own
1873
+ file. `[types.scalars]` and `[types.containers]` may only replace mappings the backend already
1874
+ defines — neutral type names are a fixed vocabulary, so a key outside it is a typo, and the error
1875
+ suggests the near miss; `[imports.rules]` does accept new keys, because retargeting a scalar
1876
+ requires an import rule keyed on the new type's prefix. There is no `[backend]` section: manifest
1877
+ selection stays a pure function of `(backend, engine)`. Every failure — unknown section, unknown
1878
+ key, missing file — fails `scythe generate` naming the backend, the resolved absolute path and the
1879
+ offending key, and nothing falls back to the compiled-in manifest silently
1880
+ ([#82](https://github.com/Goldziher/scythe/issues/82))
1881
+ - A live nullability conformance suite (`scythe-conformance`), a dev-only workspace member that
1882
+ compares inferred nullability against what engines actually return rather than against scythe's
1883
+ own model. Per (fixture, engine, column) it holds three facts side by side: the analyzer's
1884
+ verdict, whether the generated code actually *renders* the column as optional (parsed out of the
1885
+ resolved type against the backend manifest, deliberately not copied from the analyzer, so the two
1886
+ can genuinely disagree), and the engine's observed per-row nullness from a real query run. Four
1887
+ assertions relate them: fidelity (analyzer and generated code agree), soundness (an observed NULL
1888
+ implies the generated code renders the column optional), anti-vacuity (a column called nullable
1889
+ must be demonstrated NULL by some run, or the suite is satisfied by marking everything nullable),
1890
+ and join-group coherence (columns widened by the same outer join go NULL together). Accepted
1891
+ over-pessimism — the analyzer is stricter than an engine turns out to be — goes in a capped
1892
+ registry with a tracking issue per entry, and an entry that stops reproducing fails the build, so
1893
+ fixing the gap forces deleting the entry that excused it. A soundness failure is never
1894
+ suppressible by any registry entry. The crate is unpublished, has no CLI surface, and nothing in
1895
+ `scythe generate` touches it
1896
+ - Live drivers in that suite for all six engines — PostgreSQL, MySQL, MariaDB, SQLite, SQL Server and
1897
+ Oracle — each behind its own Cargo feature plus a `live-tests` gate, with one CI job per engine. No
1898
+ driver is linked by default, so `cargo test --workspace` exercises the pure comparison logic
1899
+ without a container. Selecting an engine whose feature was not compiled in is a hard error naming
1900
+ the feature to enable, never a silent skip. Each engine's isolation is its own problem: SQL Server
1901
+ gets a fresh database per connection, because T-SQL's default schema belongs to the database
1902
+ principal rather than the session and `USE` does not survive tiberius routing statements through
1903
+ `sp_executesql`, so tables would otherwise land in `master`; Oracle gets a user per connection,
1904
+ because in Oracle a schema is a user. Fixtures are now analyzed under their own engine's dialect
1905
+ rather than PostgreSQL's, which is what made the Oracle empty-string bug below observable
1906
+ ([#71](https://github.com/Goldziher/scythe/issues/71))
1907
+ - **A provenance header in every generated file**, recording the scythe version, backend, engine, a
1908
+ fingerprint of the schema and a fingerprint of the query set the file was generated from:
1909
+
1910
+ ```text
1911
+ // scythe:provenance v=0.14.0 backend=go-pgx engine=postgresql schema=sch1:2e813606acee8b51 queries=q1:9c4e1f77a0b3d582
1912
+ ```
1913
+
1914
+ The comment token follows the target language (`#` for Python, Ruby and Elixir), and where a
1915
+ language requires particular first bytes the header goes second — after `<?php`, after Ruby's
1916
+ `# frozen_string_literal: true`. Python's variant carries a trailing `# noqa: E501`, since the line
1917
+ exceeds ruff's default 88-column limit and would otherwise fail `ruff check` on line 1 of every
1918
+ generated Python file. Ruby's `queries.rbs` signature file gets one too.
1919
+
1920
+ The schema fingerprint is a SHA-256 over a canonical rendering of the *resolved* catalog — tables,
1921
+ columns, enums, composites, domains, dialect — rather than over DDL text, so reformatting a
1922
+ migration or reordering statements does not move it while a real schema change does. It excludes
1923
+ column defaults (free-form AST text that churns on dependency bumps) and scythe's own version,
1924
+ which would otherwise report every artifact as drifted on every release.
1925
+
1926
+ The query fingerprint covers the *analyzed* query set — each query's name, command, parameter names
1927
+ and types, and resolved column names, types and nullability — rather than the SQL text, so
1928
+ reformatting a `.sql` file or editing a comment does not report drift while a change that moves a
1929
+ generated signature does. Parameter names participate because every backend emits them as the
1930
+ generated function's argument names: swapping `WHERE name = $1` for `WHERE email = $1` leaves both
1931
+ parameters typed `string` but rewrites the signature from `name: &str` to `email: &str`, breaking
1932
+ every caller. Schema drift and query drift are reported as distinct findings, `SC-PRV01` and
1933
+ `SC-PRV08`.
1934
+
1935
+ Generated code is only as correct as the schema snapshot scythe read, and nothing in the artifact
1936
+ recorded which snapshot that was. Code generated against a drifted local schema compiles, reviews
1937
+ as an ordinary diff, and meets a different migration state in production. Raised by **Mads
1938
+ Hansen**.
1939
+
1940
+ `scythe check` verifies it through seven rules: `SC-PRV01` schema drift, `SC-PRV03` backend drift
1941
+ and `SC-PRV04` engine drift as errors; `SC-PRV02` scythe-version drift, `SC-PRV05` missing header,
1942
+ `SC-PRV06` malformed header and `SC-PRV07` unverifiable header as warnings. They are ordinary
1943
+ registry rules, so `[lint.rules]` and `[lint.categories]` can downgrade or disable any of them. A
1944
+ scythe upgrade alone is a warning by design — upgrading the tool must never fail a consumer's CI
1945
+ before they have had a chance to regenerate. A missing artifact produces no finding at all, since
1946
+ the default `.gitignore` excludes `**/generated/`.
1947
+
1948
+ It answers "was this generated from this schema?", not "from these queries?" — editing a query file
1949
+ without touching the schema produces no mismatch
1950
+ ([#68](https://github.com/Goldziher/scythe/issues/68))
1951
+ - **`scythe check --database-url` now also diffs your DDL against the live database.** PostgreSQL
1952
+ only; blocks on other engines are skipped with a warning naming the block. Seven `SC-DRF` rules
1953
+ cover tables and columns missing from either side, type mismatches, nullability mismatches and enum
1954
+ value mismatches — all errors except `SC-DRF02`, a table present in the database but not in your
1955
+ DDL, which is a warning because every real database has a `schema_migrations` table scythe knows
1956
+ nothing about.
1957
+
1958
+ `SC-DRF06` is the rule that justifies the feature. Query verification cannot check nullability:
1959
+ preparing a statement makes PostgreSQL report type OIDs and nothing about NULL-ness. Reading
1960
+ `pg_attribute.attnotnull` is the only way scythe can tell you a `NOT NULL` in your DDL is not true
1961
+ in production, where the generated non-optional field fails to decode the first NULL row it meets.
1962
+
1963
+ The catalog is read from `pg_catalog`, not `information_schema`, which reports `USER-DEFINED` for
1964
+ every enum column and never names the type — the enum and type-mismatch rules would be undetectable
1965
+ through it. Type comparison is exact equality rather than the tolerant predicate query verification
1966
+ uses, which forgives string widening and so reported nothing when a `text` column became `uuid`.
1967
+ Types neither side can express in scythe's neutral vocabulary are skipped rather than reported as
1968
+ mismatches. Views and materialized views are excluded from the nullability check, since PostgreSQL
1969
+ stores `attnotnull = false` for every view column.
1970
+
1971
+ Opt-in via the flag: with no `--database-url` nothing connects, and unlike `scythe inspect`, `check`
1972
+ never falls back to `$DATABASE_URL` — it cannot start requiring a database because that variable
1973
+ happens to be set, which is what keeps it usable in a pre-commit hook.
1974
+
1975
+ This is the cheaper intermediate the issue proposes, not its headline `schema_source = "execute"`
1976
+ design: scythe still builds its catalog by parsing DDL and does not execute your migrations against
1977
+ an ephemeral database, so DDL that only a real engine can resolve is still out of reach. Raised by
1978
+ **u/Character-Forever-91** ([#79](https://github.com/Goldziher/scythe/issues/79))
1979
+ - **Nested struct types inferred from `json_agg(alias.*)` and `row_to_json(alias.*)`.** A column that
1980
+ aggregates a whole relation now resolves to a generated struct with that relation's fields instead
1981
+ of an opaque JSON scalar. PostgreSQL and CockroachDB only, and only on `rust-sqlx`,
1982
+ `rust-tokio-postgres`, `go-pgx` and `python-psycopg3` — every other backend degrades to exactly the
1983
+ plain `json` mapping it produced before, including on Redshift, where `json_agg` does not exist.
1984
+
1985
+ Element nullability is modelled on the element, not the fields. `json_agg` over a LEFT JOIN emits a
1986
+ JSON `null` element, never an object of null fields, so an inner join yields
1987
+ `Vec<GetUserOrdersRowOrders>` and an outer join `Vec<Option<GetUserOrdersOuterRowOrders>>`.
1988
+ Widening the fields instead would model a value PostgreSQL never produces while leaving the type
1989
+ unable to hold the one it does.
1990
+
1991
+ JSON keys are the raw SQL column names, so a quoted `"createdAt"` column gets `#[serde(rename)]` in
1992
+ Rust, a `json:"createdAt"` struct tag in Go, and an explicit `_from_json` classmethod in Python —
1993
+ `Cls(**item)` would pass `createdAt` as an unexpected keyword argument. Enums reachable only
1994
+ through a nested struct are emitted with per-variant renames, since the driver's own
1995
+ `rename_all` tells serde nothing.
1996
+
1997
+ `jsonb_agg` is deliberately not covered, nor is `json_agg` over a scalar or a bare `*`. Two queries
1998
+ in one file deriving the same struct name deduplicate if their shapes match and are a hard error
1999
+ naming both if they do not. Your own `@json` annotations are untouched
2000
+ ([#78](https://github.com/Goldziher/scythe/issues/78))
2001
+ - **A `field_case` option** on a `[[sql.gen]]` target, accepting `snake_case` (the default) or
2002
+ `camelCase`, honored by the 11 TypeScript backends and by `java-jdbc`, `java-r2dbc`, `kotlin-jdbc`,
2003
+ `kotlin-r2dbc` and `kotlin-exposed`. It renames generated field and parameter names only; every
2004
+ backend still reads the driver row by the raw SQL column name, so the rename cannot break decoding.
2005
+
2006
+ On TypeScript the naive version of this would ship a type that lies: 10 of the 11 backends return
2007
+ the driver's row through a blind `rows[0] as StructName` cast, so renaming the declared field alone
2008
+ type-checks green and returns `undefined` for every field at runtime — `tsc` certifies the bug.
2009
+ Under `camelCase` the function body therefore reconstructs the row field by field, reading raw keys
2010
+ and writing renamed ones ([#87](https://github.com/Goldziher/scythe/issues/87))
2011
+ - **Four JSDoc `javascript-*` backends**: `javascript-pg`, `javascript-postgres`,
2012
+ `javascript-mysql2` and `javascript-better-sqlite3`. They emit plain ESM `.js` carrying its types
2013
+ entirely in JSDoc comments — `@typedef`/`@property` for row types, `@param`/`@returns` for
2014
+ functions — with no driver import statement, referencing driver types inline as
2015
+ `import("pg").PoolClient`. Nullability is always `T | null`, never the optional-property form.
2016
+ These are an emit mode on the existing TypeScript backends rather than new manifests, so the
2017
+ manifest count is unchanged. `row_type = "zod"`, `outer_join_unions` and `field_case = "camelCase"`
2018
+ are rejected with an error naming the TypeScript backend to use instead: each needs syntax a plain
2019
+ `.js` file cannot carry. Output is validated in CI with real `node --check` and
2020
+ `tsc --checkJs --strict` ([#81](https://github.com/Goldziher/scythe/issues/81))
2021
+ - `--exit-zero` on `scythe check`, matching the flag `audit` and `inspect` already had
2022
+ - **A `queries=` fingerprint in the provenance header**, covering the analyzed query set alongside
2023
+ the schema. The schema fingerprint said nothing about the `.sql` files, so editing a query and
2024
+ forgetting to regenerate left an artifact that `scythe check` called clean. Computed over each
2025
+ query's name, command, parameter names and types, and resolved column names, types and
2026
+ nullability — not the SQL text — so reformatting a query or editing a comment stays silent while a
2027
+ change that moves a generated signature does not. Parameter names participate because every
2028
+ backend emits them as the generated function's argument name: swapping `WHERE name = $1` for
2029
+ `WHERE email = $1` leaves both typed `string` but rewrites the signature from `name: &str` to
2030
+ `email: &str`, breaking every caller. Reported as `SC-PRV08` (`query-drift`, Error), distinct from
2031
+ `SC-PRV01`, so a drift report names which of the two moved. An artifact whose header predates this
2032
+ field is not reported as malformed ([#94](https://github.com/Goldziher/scythe/issues/94))
2033
+ - **`ErrorCode::InvalidConfig`**, so a mistake in `scythe.toml` no longer surfaces under
2034
+ `INTERNAL_ERROR` and read as a scythe bug rather than something the user can fix. `ErrorCode` is
2035
+ now `#[non_exhaustive]`, so adding a future variant is no longer a breaking change ([#102](https://github.com/Goldziher/scythe/issues/102))
2036
+ - Live nullability coverage for seven more rules: `MAX`/`AVG` over an empty set, `NULLIF` with equal
2037
+ operands, `CASE` with no `ELSE`, a scalar subquery matching no row, `RIGHT JOIN` and `FULL JOIN`.
2038
+ Each is asserted against real engines rather than against the analyzer's own model. `FULL JOIN`
2039
+ joins users to tags rather than users to orders, because the foreign key on `orders.user_id` means
2040
+ no order can ever be unmatched and the join would degenerate to a `LEFT JOIN` — proving half the
2041
+ rule while appearing to prove all of it. It is scoped away from MySQL and MariaDB, which parse
2042
+ `FULL` as a table alias and reject the query ([#71](https://github.com/Goldziher/scythe/issues/71))
2043
+
2044
+ ### Changed
2045
+
2046
+ - **The README is a front page again, and its code is checked.** It was 412 lines, 227 of them ten
2047
+ hand-written samples of "generated" code that no tool validated — and five of the ten were wrong,
2048
+ including a Go block still showing pre-0.14.0 field casing and typing `NUMERIC` as `*string`. It
2049
+ now carries one Rust sample copied verbatim from committed generated output, and `README.md` is
2050
+ in `snippet-runner`'s reference set so CI compiles it. The feature list and the language/database
2051
+ matrix moved to the docs pages that own them.
2052
+ - **The documentation was audited against the source and corrected.** Seven claims contradicted the
2053
+ implementation: the unknown-option rule was described as TypeScript-only; `[lint.sqruff] enabled`
2054
+ was documented as a working toggle when nothing reads it; `[lint.sqruff.rules]` was documented as
2055
+ the opposite of the allowlist it actually builds; `--dialect` on `lint`/`fmt` was described as
2056
+ unset; the crate table omitted `audit` and `inspect`; `scythe fmt` was described as running
2057
+ sqruff's full default rule set, when `LT01` is excluded there too; and
2058
+ `[sql.gen.python|typescript|go|kotlin]` were supported but undocumented. Per-language backend
2059
+ pages replace the combined Java/Kotlin page and the "Other" grab-bag, with the old URLs kept as
2060
+ stubs.
2061
+ - **`llms.txt` generation no longer destroys the code samples.** `minify.collapseCodeBlocks` was
2062
+ enabled, which collapses whitespace inside code fences as well as prose — so the abridged file
2063
+ rendered the whole site as 258 lines with every sample unparseable. It is off; the changelog and
2064
+ Starlight's anchor markup (22% of the corpus between them) are excluded; and `llms.txt` now
2065
+ carries the facts a model gets wrong by default, above all that the annotation syntax is not
2066
+ sqlc's. Backends, databases and guide are addressable as separate sets.
2067
+ - **Generated-code tool validation reports a skipped checker as a skip, not a pass.**
2068
+ `validate_with_tools` returned `Option<Vec<String>>`, where `None` meant "tool not installed" and
2069
+ every call site spelled `if let Some(errors)` — so a checker that was never installed was
2070
+ indistinguishable from one that ran and found nothing. In practice 31 of 76 backend tests were
2071
+ passing without any tool touching the generated code: 13 because `biome` was installed nowhere,
2072
+ and 18 because Java, C#, Elixir and Rust have no validator at all. `validate_python_tools` was the
2073
+ worst case, returning `Some([])` when `ruff` was absent. The return type is now `ToolValidation`,
2074
+ reporting each checker separately as `Ran`/`Missing`/`Failed`, and CI runs with
2075
+ `SCYTHE_VALIDATE_STRICT=1`, where a missing tool fails the build instead of being skipped
2076
+ ([#98](https://github.com/Goldziher/scythe/issues/98))
2077
+ - **Generated code is checked by `poly`**, this repository's linter, rather than by a per-language
2078
+ collection of separately-installed binaries. poly bundles its engines in-process -- `oxc` for
2079
+ TypeScript, `ruff` for Python, `mago` for PHP -- so one already-required tool replaces `biome`,
2080
+ standalone `ruff`, the `python3 -m ast` syntax pass and `php -l`, and CI drops four install steps
2081
+ along with the Python, PHP and JDK toolchains it only needed in order to feed them. `node` and
2082
+ `tsc --checkJs --strict` remain for the `javascript-*` JSDoc backends, since oxc lints JavaScript
2083
+ but does not typecheck JSDoc annotations; `gofmt` and `ruby -c` remain because poly delegates those
2084
+ languages rather than bundling them. Kotlin loses its tool validation: poly delegates to `ktlint`,
2085
+ and standing up a JVM plus a downloaded jar to lint generated Kotlin is out of proportion to what
2086
+ it catches -- `validate_structural` still covers those backends, and an inventory test keeps the
2087
+ gap visible. Validation runs against a dedicated `generated-code-poly.toml` passed explicitly,
2088
+ because poly resolves config by walking up from the file it is handed and a temporary file finds
2089
+ nothing, so what CI enforced would otherwise depend on where the system temp directory sits
2090
+ - **Unknown `[[sql.gen]]` keys are rejected on every backend**, not just TypeScript. 24 of the 52
2091
+ backends had no `apply_options` at all and inherited a permissive default that accepted anything
2092
+ ([#103](https://github.com/Goldziher/scythe/issues/103))
2093
+
2094
+ - **`scythe check` exits `2` for findings and `1` for operational failures.** It previously exited
2095
+ `1` for both, so a CI script could not distinguish "your schema drifted" from "your config file is
2096
+ missing". Any script or hook keying on `1` for findings must change to `2`, or use `--exit-zero`
2097
+ for an advisory gate. Warnings have never affected the exit code and still do not
2098
+ - **Unrecognized options on any `[[sql.gen]]` target are now a hard error.** Every backend previously
2099
+ inherited the default `apply_options`, which silently discarded any key it did not read —
2100
+ `row_typ = "zod"` parsed as valid TOML and did nothing, with no diagnostic. This was fixed for the
2101
+ 11 TypeScript backends first; the same typo behaving differently depending on target language was
2102
+ itself a trap, so the `CodegenBackend` trait default now rejects every key unless a backend
2103
+ declares it known, closing the gap for the other 41 backends in one change
2104
+ ([#103](https://github.com/Goldziher/scythe/issues/103)). Unknown keys fail generation, with a
2105
+ suggestion when the key is within edit distance 2 of a real one. A config carrying a
2106
+ forward-compatibility key on any target will fail on upgrade
2107
+ - **Identifiers derived from names with consecutive capitals change spelling.** PascalCase conversion
2108
+ previously returned mixed-case input containing no underscore unchanged, so a query named
2109
+ `CreateAPIKey` generated the function `createApiKey` returning the type `CreateAPIKeyRow` — the
2110
+ same query, spelled two ways. Both sides now normalize identically: `CreateAPIKeyRow` becomes
2111
+ `CreateApiKeyRow`. This affects row, enum and composite type names on every backend, and function
2112
+ names on the 16 backends whose manifests use PascalCase function naming (all `csharp-*` and all
2113
+ `go-*`). Names that are snake_case, or PascalCase without consecutive capitals, are unaffected
2114
+ - **Two SQL columns whose names collapse onto one field name are now a hard error.** `SELECT
2115
+ "USER_ID", user_id FROM t` is legal SQL and passes the analyzer's case-sensitive duplicate-alias
2116
+ check, which runs on raw names before conversion; it previously emitted a struct with two
2117
+ identically-named fields. This applies on every backend, including under the default `snake_case`,
2118
+ and covers parameters as well as columns
2119
+ - **The `Auto-generated by scythe. Do not edit.` banner is gone**, replaced by the provenance header,
2120
+ which carries the same warning plus the version, backend, engine and schema fingerprint — and which
2121
+ `scythe check` verifies rather than merely stating. Removed from 40 of the 52 backends; the Go,
2122
+ Kotlin and Elixir backends never emitted it. Go's `// Code generated by scythe. DO NOT EDIT.` line
2123
+ is unchanged, since the Go toolchain matches on it. Together with the header, the first
2124
+ regeneration after upgrading touches every generated file
2125
+
2126
+ ### Fixed
2127
+
2128
+ - **`[sql.gen.rust] serde` and `derive` failed on three of the four Rust backends.** Both keys are
2129
+ documented on the legacy table independently of `target`, and the CLI puts them into the options
2130
+ map whichever backend was selected — but only `rust-tokio-postgres` recognized them.
2131
+ `rust-sqlx` accepted `structs_only` alone, and `rust-tiberius` and `rust-sibyl` declared no
2132
+ options at all, so the reject-by-default trait default turned the documented config into
2133
+ `unknown option 'serde'`. All four now accept both keys. Emitted output is unchanged when neither
2134
+ is set.
2135
+ - **`scythe audit --list-rules` under-reported the rule set by two.** It printed 56 rules against a
2136
+ registry of 58, and `--explain SC-A02` reported no such rule. Both built their catalog from the
2137
+ active-rule set, which drops anything resolving to `off` — correct for deciding what runs, wrong
2138
+ for a catalog. `SC-A02` and `SC-C01` are off by default but are registered rules a user can
2139
+ enable, and they now appear with their `off` severity. What actually fires is unchanged.
2140
+ - **The schema fingerprint could report drift that was not real, and miss a change that was.**
2141
+ Schema-qualifier stripping was gated on PostgreSQL although `Catalog::get_table` is dialect-blind,
2142
+ and it stripped only `public.` where `get_table` strips any prefix, so `myschema.users` and
2143
+ `users` diverged. Enum values were emitted unescaped, so `ENUM ('a|b')` and `ENUM ('a','b')`
2144
+ produced an identical canonical line, and a value containing a tab or newline could forge an
2145
+ entire extra record. `CREATE DOMAIN` was absent from the canonical form. The escaping scheme
2146
+ escapes only when a delimiter is actually present, so every fingerprint in the corpus is unchanged
2147
+ and `FINGERPRINT_ALGORITHM_TAG` is deliberately not bumped — bumping it would hand every user a
2148
+ spurious drift report on upgrade. Eight fixture fingerprints are now pinned to their released
2149
+ values ([#91](https://github.com/Goldziher/scythe/issues/91))
2150
+ - **`scythe migrate` wrote configs that could not generate.** A stock sqlc-for-Go config produced
2151
+ `backend = "go-go"`, since the language and target were concatenated unconditionally. Kotlin was
2152
+ worse: it had no field in the legacy config at all, so a migrated Kotlin project silently emitted
2153
+ `rust-sqlx` output. This is the on-ramp for every sqlc user ([#97](https://github.com/Goldziher/scythe/issues/97))
2154
+ - **Generated Go failed to compile against a schema with no temporal or decimal column**, because
2155
+ the import block was emitted unconditionally across `go-pgx`, `go-godror` and `go-gosnowflake`.
2156
+ `gofmt -e` parses but does not typecheck, so it could never have caught an unused import
2157
+ ([#100](https://github.com/Goldziher/scythe/issues/100))
2158
+ - **`ruby-sqlite3` and `ruby-tiny-tds` emitted an `.rbs` signature contradicting the `.rb` beside
2159
+ it**, because the RBS generator hardcoded the `json` type instead of following the manifest.
2160
+ Manifest scalars are Ruby *doc* names rather than RBS types, so this needed a translation table,
2161
+ not a passthrough ([#101](https://github.com/Goldziher/scythe/issues/101))
2162
+ - **`WITH t(a, b) AS (...)` ignored the column alias list.** A CTE's explicit column names were never
2163
+ applied to the analyzed scope, so the outer query could not reference them: `WITH t(a, b) AS
2164
+ (SELECT 1, 2) SELECT a, b FROM t` failed with "column a does not exist", because a body projection
2165
+ carrying no names of its own labels its columns `unknown`. The alias list is now applied at all
2166
+ three registration points -- the recursive anchor's seed, the widened recursive union shape, and
2167
+ the plain fall-through path -- and an alias count that disagrees with the body's column count is
2168
+ rejected the way PostgreSQL rejects it, rather than being matched positionally into mislabelled
2169
+ columns. Contributed by **Znie** ([#107](https://github.com/Goldziher/scythe/pull/107))
2170
+ - **`LEAD`/`LAG` were always inferred nullable**, even when both the argument and the three-argument
2171
+ default are non-null. `IGNORE NULLS` bails out, since it can return NULL regardless ([#89](https://github.com/Goldziher/scythe/issues/89))
2172
+ - `typescript-kysely` output now carries a note recording that it requires `CamelCasePlugin`
2173
+ ([#96](https://github.com/Goldziher/scythe/issues/96))
2174
+ - The grouped-fold row reads in `typescript-pg` and `typescript-mysql2` are cast in TypeScript mode,
2175
+ matching every other read site. The two `js_mode` sites stay uncast, since `as T` is not valid
2176
+ JavaScript ([#95](https://github.com/Goldziher/scythe/issues/95))
2177
+
2178
+ - **`csharp-snowflake` generated parameter bindings that Snowflake rejects.** Generated code named
2179
+ each positional binding `p1`, `p2`, `p3`, but Snowflake's REST protocol keys `?` placeholders by
2180
+ bare ordinal, so the server read them as *named* bindings and the query failed. Bindings are now
2181
+ named `"1"`, `"2"`, `"3"`. The backend had shipped since 0.6.0 without ever running anywhere: it
2182
+ was held out of the Snowflake integration job on the diagnosis that fakesnow's binding-name
2183
+ heuristic was at fault, and 0.12.0 recorded that as a fakesnow limitation rather than a codegen
2184
+ one. The diagnosis was backwards — fakesnow was right to reject `p1`, and real Snowflake would
2185
+ have rejected it too. The backend now runs against the shared fakesnow server in CI
2186
+ - **`scythe migrate` silently converted nothing when the project directory contained a glob
2187
+ metacharacter.** The pattern used to find `.sql` query files was built by joining the base
2188
+ directory onto the `queries` entry, and the "is this already a glob, or a bare directory needing
2189
+ `/*.sql`" decision was then made on the *joined* string. Neither step escaped the base directory,
2190
+ so a project in a directory named e.g. `a[b]` had its `[b]` compiled as a glob character class,
2191
+ matched no files, and reported `Migration complete: 0 file(s) converted` instead of converting
2192
+ anything — the same silent-zero failure mode #84 fixed for `generate`/`check`/`lint`/`audit`/`fmt`
2193
+ in 0.13.0. The base directory is now escaped with `glob::Pattern::escape` and joined with `/` on
2194
+ every platform, and the directory-vs-glob decision is made on the raw pattern, never on the string
2195
+ after the base directory has been prefixed onto it
2196
+ ([#88](https://github.com/Goldziher/scythe/issues/88))
2197
+ - `task version:check` asserted that every crate's own version matched `scythe-cli`'s, including
2198
+ crates marked `publish = false`. An unpublished crate never reaches crates.io, so its version
2199
+ carries no meaning and `version:sync` deliberately leaves it alone — which made the two steps
2200
+ contradict each other, with no version that could satisfy both. Unpublished crates are now exempt
2201
+ from the own-version check; their inter-crate pins are still checked
2202
+ - **Oracle's empty string literal is NULL, and the analyzer did not know it.** Oracle is alone in
2203
+ treating `''` as NULL, so `SELECT COALESCE(email, '') AS email_or_empty` was typed non-optional —
2204
+ `String` rather than `Option<String>` — and the driver could not decode the first row where Oracle
2205
+ returned NULL. The literal now carries the right nullability under the Oracle dialect, which
2206
+ propagates through `COALESCE`, `CASE ... ELSE ''` and concatenation. The other five dialects are
2207
+ unaffected. `NVL` is not covered, though it was already optional by a different route. Found by the
2208
+ live Oracle conformance leg; a model-only fixture could never have caught it, since it compares the
2209
+ analyzer against the same model it is built from
2210
+ - **`typescript-duckdb` read every row positionally while indexing it by name.** The generated code
2211
+ called `getRows()`, which returns positional arrays, then read fields by property name — so every
2212
+ field came back `undefined` at runtime, with no `tsc` error because the row cast is unchecked. It
2213
+ now calls `getRowObjects()`. Present since the backend shipped in 0.6.0; there is no
2214
+ `typescript-duckdb` integration project, which is why nothing caught it
2215
+ - **`typescript-oracledb` cast nullable columns to their non-null type.** Three sites — both read
2216
+ paths and the `RETURNING` out-binds path — cast to the column's base type while the declared
2217
+ interface said `| null`, so a null column was typed as though it could never be null
2218
+ - **The TypeScript discriminated-union row type omitted some columns entirely.** With
2219
+ `outer_join_unions = true`, a column belonging to a join group that carries no discriminant — one
2220
+ where every projected column was already nullable in the schema — matched neither the base-field
2221
+ loop nor any union variant, so it was declared nowhere. A query selecting five columns produced a
2222
+ row type declaring three. The Zod form of the same function had the identical defect, despite its
2223
+ contract that the two shapes cannot drift apart
2224
+ - **Provenance verification could discard every lint finding.** A target whose backend and engine
2225
+ pair failed to construct — a config with no `[[sql.gen]]` block synthesizes a `rust-sqlx` target,
2226
+ which does not support every engine `check` accepts — aborted the run before findings were emitted,
2227
+ so `check` exited with an error and an empty SARIF report while real findings existed. Verification
2228
+ now cannot unwind past emission. Related: the header was compared against the raw backend alias
2229
+ from the config rather than the canonical name, so a target written as `sqlx` reported backend
2230
+ drift against its own output forever
2231
+ - **`task version:sync` invalidated every generated artifact.** The provenance header embeds the
2232
+ scythe version, so bumping it made all committed artifacts stale and failed the generated-freshness
2233
+ gate on the release commit itself — on every future release, not just this one. `version:sync` now
2234
+ regenerates after bumping and rewrites the version in documented examples, and CI carries a guard
2235
+ comparing every committed header against the workspace version
2236
+
2237
+ ## [0.13.0] - 2026-08-07
2238
+
2239
+ This release makes generation depend on committed inputs rather than on where the command was run
2240
+ from, and widens distribution to Node and Python.
2241
+
2242
+ ### Added
2243
+
2244
+ - npm and PyPI wrapper packages for the CLI, so Node and Python teams can pin scythe as a dev
2245
+ dependency without installing a Rust toolchain. The npm package is
2246
+ [`scythe-cli`](https://www.npmjs.com/package/scythe-cli) and the PyPI package is
2247
+ [`scythe-sql`](https://pypi.org/project/scythe-sql/); both expose the binary as `scythe`. Each
2248
+ resolves the host platform to a release target triple, downloads the matching asset, verifies its
2249
+ SHA-256 against the release checksums file, and unpacks it. They are shims over assets the release
2250
+ already produced, so the build matrix is unchanged ([#80](https://github.com/Goldziher/scythe/issues/80))
2251
+ - The two platform gaps are handled deliberately rather than silently. musl Linux has no published
2252
+ asset and the gnu binary dies at exec with an opaque loader error, so it fails at install time
2253
+ naming the platform. Windows on ARM also has no asset, but the x64 binary runs under emulation, so
2254
+ it falls back with a warning rather than blocking a configuration that works
2255
+ - Both wrappers work behind a corporate proxy and a TLS-intercepting one: they honour `HTTPS_PROXY`,
2256
+ `NO_PROXY` and npm's or pip's own proxy settings, and read a CA bundle from `npm_config_cafile` or
2257
+ `NODE_EXTRA_CA_CERTS`. The cached binary is written through a temp file and renamed into place, so
2258
+ an interrupted install leaves no truncated binary for the next run to trust
2259
+ - `task version:check` fails on either a crate whose own version disagrees with `scythe-cli`'s or an
2260
+ inter-crate pin that does. `version:sync` now runs it, so a partial version bump can no longer
2261
+ reach a tag
2262
+
2263
+ ### Fixed
2264
+
2265
+ - **`scythe.toml` paths resolved against the working directory, so `--config` was close to unusable
2266
+ from outside the project.** `scythe generate --config /path/to/project/scythe.toml` run from
2267
+ anywhere else silently found no schema and no queries, and a `scythe.toml` could not describe its
2268
+ own project independently of where it was invoked from. Paths now resolve against the directory
2269
+ containing the config file — see Breaking Changes below ([#84](https://github.com/Goldziher/scythe/issues/84))
2270
+ - **`task generate:all` regenerated with whatever `scythe` was first on `$PATH`.** With an older
2271
+ release installed via `cargo install`, it silently rewrote committed output backwards, printed
2272
+ `Done.` per backend and exited 0. During the 0.12.0 release this reverted four files from the
2273
+ SQLite `int64` fix back to `int32`, and the damage was indistinguishable from legitimate
2274
+ regeneration. The task now builds `scythe-cli` from the workspace and invokes it by absolute path,
2275
+ matching what CI's freshness job already did ([#85](https://github.com/Goldziher/scythe/issues/85))
2276
+ - **`task version:sync` silently skipped `scythe-inspect`**, which was absent from both `sed` file
2277
+ lists and missing from the second `sed`'s crate alternation. Because `publish_crates` tolerates an
2278
+ "already exists" error from crates.io, a release would publish five crates, skip the sixth and
2279
+ report success — while the published `scythe-cli` declared a dependency on the *previous*
2280
+ `scythe-inspect`, which resolves fine and therefore never surfaces
2281
+ - Snowflake typed the same underlying storage three different widths depending on spelling. Snowflake
2282
+ aliases every integer spelling — `INT`, `INTEGER`, `BIGINT`, `SMALLINT`, `TINYINT` — to
2283
+ `NUMBER(38,0)`, but only `BIGINT` resolved to `int64`; `SMALLINT` and `TINYINT` fell through to
2284
+ `int16` and `INT`/`INTEGER` to `int32`. `REAL` and `FLOAT4` likewise reported `float32` for what
2285
+ Snowflake stores as an 8-byte double. See Breaking Changes
2286
+ ([#83](https://github.com/Goldziher/scythe/issues/83))
2287
+ - `NUMBER(p,s)` with a non-zero scale is now scale-aware. Through the DDL path this was already
2288
+ handled upstream by `normalize_data_type`, but the AST path — `CAST` and parameter inference —
2289
+ reached the bare `number` arm and typed a decimal as `int64`. `NUMBER(p,0)` and bare `NUMBER` keep
2290
+ `int64`
2291
+ - Types that had no arm at all and fell through as unknown, erroring only later at the backend
2292
+ boundary: `INT1`, `HUGEINT`/`UHUGEINT` (DuckDB), `MONEY`/`SMALLMONEY` (MSSQL and PostgreSQL),
2293
+ `XML` (MSSQL and PostgreSQL), `BYTEINT` (Snowflake's synonym for `TINYINT`) and
2294
+ `GEOGRAPHY`/`GEOMETRY`. The 128-bit DuckDB integers map to `decimal` rather than a silently
2295
+ truncating `int64` — no integer neutral type is wide enough. `GEOGRAPHY`/`GEOMETRY` had been
2296
+ documented as `string` since the Snowflake page was written, with no code behind it
2297
+ - **An explicit `NUMBER(p,0)` resolved to `decimal` through the schema path**, because catalog
2298
+ normalization rewrote every two-token `NUMBER(p,s)` to `numeric(p,s)` regardless of the scale, so
2299
+ a zero scale reached the decimal arm. `NUMBER(38,0)` is exactly what Snowflake's `DESCRIBE TABLE`
2300
+ reports for `INT`, so a schema reverse-engineered from a live table typed its keys `decimal` while
2301
+ the same table written with `INT` typed them `int64` — the spelling-dependent inconsistency #83
2302
+ set out to end, still reachable by a different route. `oracle.md` had documented the correct
2303
+ behaviour (`NUMBER(*, 0)` → `int64`) all along ([#86](https://github.com/Goldziher/scythe/issues/86))
2304
+ - The unit test guarding zero-scale `NUMBER` passed a hand-built string straight to the conversion
2305
+ function, which is not the spelling the schema path produces — so it stayed green while real
2306
+ schemas resolved the other way. The type-mapping regressions now drive the whole pipeline
2307
+ - `verify-binstall` never ran on a release re-run, because `release_assets` is *skipped* rather than
2308
+ successful when the assets already exist
2309
+ - The release workflow's "already published" probe against crates.io sent no `User-Agent`, which
2310
+ their data-access policy answers with `403`. The check therefore always reported "not published",
2311
+ so a re-run replayed the full publish chain and its 30-second inter-crate sleeps
2312
+ - The documented pre-commit `rev:` pins in the guide were bumped by nothing and validated by nothing,
2313
+ so they still pointed at the previous release. `version:sync` now rewrites them and `version:check`
2314
+ fails on drift
2315
+
2316
+ ### Changed
2317
+
2318
+ - `UNSIGNED` is now documented on the MariaDB page, which inherits it from the MySQL dialect but
2319
+ never mentioned it
2320
+
2321
+ ### Breaking Changes
2322
+
2323
+ - **Paths in `scythe.toml` resolve against the config file's directory, not the process working
2324
+ directory.** This covers `schema` and `queries` glob patterns and `[[sql.gen]].output`. Absolute
2325
+ paths and patterns are unchanged, and a config invoked from its own directory — the overwhelmingly
2326
+ common case, including every project in this repository — behaves identically. Output moves with
2327
+ the inputs: leaving it working-directory-relative would turn a silent wrong read into a silent
2328
+ wrong write, scattering generated trees into whatever directory the command ran from. A pattern
2329
+ matching nothing is now a hard error naming the pattern, the config directory and the resolved
2330
+ pattern, since after this change an empty match is the most common symptom of a stale path
2331
+ ([#84](https://github.com/Goldziher/scythe/issues/84))
2332
+ - **Snowflake `SMALLINT`, `TINYINT`, `INT` and `INTEGER` now generate 64-bit integers**, and `REAL`
2333
+ and `FLOAT4` now generate 64-bit floats. Regenerate; in the statically typed targets this changes
2334
+ field types and driver accessors (`int` → `long`, `setInt` → `setLong`). Languages that map both
2335
+ widths to one native type — Python, TypeScript, PHP — are unaffected
2336
+ ([#83](https://github.com/Goldziher/scythe/issues/83))
2337
+
2338
+ ## [0.12.0] - 2026-08-07
2339
+
2340
+ ### Added
2341
+
2342
+ - `typescript-kysely` backend targeting [Kysely](https://kysely.dev)'s `sql` template tag instead of a specific driver, so one generated file runs against any Kysely dialect. Covered end to end against all four built-in dialects — `PostgresDialect`, `MysqlDialect` (mysql2), `SqliteDialect` (better-sqlite3) and `MssqlDialect` (tedious + tarn) — plus a MariaDB project, each running against a live container. A `redshift` manifest also ships, but has no integration project of its own — Redshift coverage is inherited from the wire-compatible PostgreSQL path, not directly tested. Supports the same `row_type` (interface/zod) and `outer_join_unions` options as the other TypeScript backends; the latter makes scythe's Kysely output strictly more precise than a hand-written Kysely query can express, since Kysely has no way to know a joined column's nullability is correlated with its schema `NOT NULL` constraint ([#66](https://github.com/Goldziher/scythe/issues/66))
2343
+ - `typescript-node-sqlite` backend targeting Node's built-in `node:sqlite` module (`DatabaseSync`), with zero npm dependencies. Requires Node 23.4+ to run unflagged (`--experimental-sqlite` on Node 22). `DatabaseSync` has no `transaction()` helper, so `:batch` queries emit explicit `BEGIN`/`COMMIT` with a rethrowing `ROLLBACK` ([#66](https://github.com/Goldziher/scythe/issues/66))
2344
+ - `typescript-wasm-sqlite` backend targeting the official [`@sqlite.org/sqlite-wasm`](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm) build via its synchronous OO1 API ([#66](https://github.com/Goldziher/scythe/issues/66))
2345
+ - Both new SQLite backends generate **fully synchronous** code — no `async`, `await` or `Promise` anywhere, asserted in tests. This was the explicit ask in [#66](https://github.com/Goldziher/scythe/issues/66): these clients are synchronous, and routing them through Kysely "introduces async promise thrashing"
2346
+ - `structs_only` now applies to every TypeScript backend, not just `rust-sqlx`. It suppresses the query functions and the driver import while still emitting interfaces, Zod schemas, enums and composites. Combined with `row_type = "zod"` this produces the types-only output requested in [#66](https://github.com/Goldziher/scythe/issues/66)
2347
+ - `scythe check --database-url` verifies inferred query types against a live PostgreSQL database using the extended query protocol (Parse/Describe), reporting mismatches as rules SC-VER01 through SC-VER05 ([#65](https://github.com/Goldziher/scythe/issues/65))
2348
+ - Opt-in `outer_join_unions` for the TypeScript backends: outer-join nullability is expressed as a discriminated union rather than independent per-column optionals, so a shape like `{ total: null, notes: "gift" }` — unreachable when `orders.total` is `NOT NULL` — is no longer admitted by the generated type. Now supported for `row_type = "zod"` as well, emitting a real `z.union([...])` ([#64](https://github.com/Goldziher/scythe/issues/64))
2349
+ - Generated TypeScript is now type-checked with `tsc --noEmit` in every TypeScript integration project and in CI. The strict `tsconfig.json` in those projects was previously decorative: `tsx` only transpiles, and the validation harness ran biome alone. This gate immediately caught several codegen defects listed under Fixed
2350
+ - SQLite coverage in the tool-validation suite via a new `sqlite_backend_test!` macro. That suite previously exercised only PostgreSQL, MySQL and DuckDB, so `typescript-better-sqlite3` had never been checked against the real TypeScript toolchain
2351
+ - `cargo binstall` support
2352
+ - `typescript-snowflake` and `go-gosnowflake` integration coverage against the shared fakesnow server ([#27](https://github.com/Goldziher/scythe/issues/27), [#61](https://github.com/Goldziher/scythe/issues/61))
2353
+ - End-to-end coverage for `outer_join_unions` (interface and Zod forms) and `structs_only`, which previously had none — every assertion was a unit test over hand-built columns, so no generated project set either option, `tsc` never checked their output and no database ever ran it. `typescript-kysely`'s test now calls all of its generated functions; six were imported and never invoked
2354
+ - A CI job that regenerates all integration code and fails if the tree moved. The integration jobs test the committed files and never regenerate, so drift meant CI was validating output no current build produces — which is exactly how the `ruby-trilogy` and `go-godror` defects above stayed hidden
2355
+ - Criterion benchmarks over the analyzer and codegen path (`task bench`). The repo previously had none, so allocation changes in the hot path were unmeasurable
2356
+ - fakesnow now serves snowflake-jdbc its native Arrow result format, dispatching per session on the login request's `CLIENT_APP_ID` so the Node, Go and .NET drivers keep the JSON path unchanged
2357
+
2358
+ ### Fixed
2359
+
2360
+ - **The integration-test generator's templates had been silently corrupted since July.** The commit that migrated linting to poly ran its prose formatter over `tools/integration-test-generator/templates/*.jinja`, because that config carried no exclusion for `.jinja` files — one was added later, but the damage was never repaired. The formatter stripped every newline and re-wrapped all seven language templates at 120 columns, which split string literals across lines and left `//` comments swallowing the code behind them. Word counts were identical before and after, so nothing was lost; the templates are restored from the last good revision with every subsequent change re-applied. The corruption stayed invisible for a month because it only reaches the tree when someone regenerates, and it surfaced as unrelated-looking compiler errors when they did. `scripts/check-generated-syntax.sh` now parses every generated harness, and the freshness job regenerates the scaffolding as well as the query code so drift in either is caught ([#72](https://github.com/Goldziher/scythe/issues/72))
2361
+ - **`scythe inspect` was unusable against every live database.** Check SC-INS13 called `round(float8, integer)`, which PostgreSQL does not define, raising SQLSTATE 42883 on every server version. Because `run_all()` was fail-fast, that one bad check aborted the entire inspection. The check is repaired and `run_all()` now isolates a failing check instead of abandoning the run
2362
+ - `:batch` queries emitted TypeScript that does not compile. When a generated signature exceeded 80 characters the line-wrapping helper discarded the signature its caller passed and rebuilt one from the query's own per-column params — so the function declared `(db, name, email)` while its body referenced `items`, an identifier that was never declared. Affected seven TypeScript backends; any `:batch` query with two or more params and a long enough name was broken
2363
+ - Oracle `CLOB`, `BLOB`, `NCLOB` and `BFILE` columns failed at runtime in the `rust-sibyl` backend with `Interface("cannot return as a String")`. These are now read through a LOB locator, and the read loop no longer discards the returned byte count (a short read previously truncated large LOBs silently)
2364
+ - Generated TypeScript did not escape SQL spliced into template literals. A backtick — idiomatic identifier quoting in MySQL/MariaDB, `` `users`.`id` `` — terminated the literal early, a backslash escaped the following character, and a literal `${` opened a live interpolation (inside a Kysely `sql` tag, a parameter binding). Newly reachable once Kysely made MySQL a supported target
2365
+ - Elixir TDS encoded a `nil` boolean parameter as `0` rather than NULL, because `nil` is falsy in Elixir — silently writing `false` where the caller meant "unknown". Also corrects the MSSQL type map: `float32`/`float64` were mapped to `:decimal` and `date` to `:datetime` ([#28](https://github.com/Goldziher/scythe/issues/28))
2366
+ - `SUM` and `AVG` result types now follow engine semantics instead of echoing the argument type: `sum(int)` widens to `int64`, `sum(bigint)` to `decimal`, and `avg(int|numeric)` yields `decimal`, matching PostgreSQL
2367
+ - `scythe check --database-url` prepared every `[[sql]]` block against the PostgreSQL connection regardless of the block's configured engine, so a MySQL or MSSQL block produced a flood of spurious SC-VER01 errors and a non-zero exit. Non-PostgreSQL blocks are now skipped with a warning, as the flag's own documentation already promised
2368
+ - `scythe check --database-url` printed the connection URL — including the password — into stderr and CI logs on a connection failure. Credentials are now redacted
2369
+ - Type verification treated `string`, `uuid`, `json` and `inet` as mutually interchangeable, so an inferred `uuid` against a reported `json` passed silently — exactly the wrongly mapped catalog type SC-VER03 exists to catch. Only one-directional widening to `string` is now accepted, and PostgreSQL domain types resolve to their base type
2370
+ - Boolean codegen options (`outer_join_unions`, `structs_only`, and others) silently coerced any unrecognised value to `false`, so `"on"`, `"TRUE"` or a typo disabled the feature without complaint. They are now parsed strictly and reject invalid values with an error naming the option
2371
+ - `csharp-oracle` emitted code that does not compile: `OracleDecimal` has no `ToDecimal()`, `bytes` parameters used the wrong `OracleDbType`, and binary columns used a reader method that does not exist for `byte[]`
2372
+ - The Zod emitter mapped every `bytes` column to `z.instanceof(Buffer)` regardless of backend — wrong for the two new SQLite backends, whose drivers yield `Uint8Array`, and unresolvable in a browser where `Buffer` does not exist. The grouped-struct Zod emitter additionally bypassed the column-aware path entirely, degrading an enum column to a bare `z.string()` instead of referencing its generated enum schema
2373
+ - `typescript-better-sqlite3`'s integration test was a no-op: the harness template had import and connection branches but no test body, so `main()` was a bare `process.exit` and the CI step passed while exercising nothing. It now runs a full create/read/update/delete round trip with assertions
2374
+ - The integration-test config templates emitted invalid TOML
2375
+ - Kysely's `:batch` threw at runtime when handed an existing transaction. `Transaction<DB> extends Kysely<DB>`, so the unconditional `db.transaction()` call nested a transaction inside itself; it now reuses the active one via `db.isTransaction`
2376
+ - CI's `poly fmt --check` went red repeatedly because `cargo-sort` (run by `poly lint`) rewrites `Cargo.toml` with a 4-space indent while poly's formatter insists on 2, so the two rewrote each other indefinitely. `Cargo.toml` is now excluded from poly's formatter, and `task update` reformats after a dependency bump
2377
+ - `INSERT INTO t VALUES (...)` with no column list registered no parameters at all — the generated function took none while the SQL carried placeholders, so it compiled and then failed at runtime on a bind-count mismatch. Values now bind positionally to the table's columns in catalog order. Placeholders nested inside function calls or `CASE` branches in `INSERT ... VALUES` and `UPDATE ... SET` were swallowed by a catch-all match arm and are now collected, keeping the target column's type, name and nullability. Contributed by [@Zniece](https://github.com/Zniece) ([#67](https://github.com/Goldziher/scythe/pull/67))
2378
+ - `ruby-trilogy` quoted only `enum::*` and `string` parameters, so `uuid`, `date`, `time`, `datetime`, `json`, `inet`, `bytes` and `interval` were interpolated bare — a UUID rendered as `WHERE id = f3373249-...`, which MySQL parses as an identifier. It is also the one Ruby backend that builds SQL by interpolation rather than binding, so any value containing an apostrophe broke the statement and was injectable. Trilogy's client has no bind API (its C extension defines only `query`, `query_with_flags` and `escape`), so every non-numeric value now goes through `Trilogy#escape`, with temporal types `strftime`-formatted and `json` serialised first
2379
+ - `go-godror` declared Oracle `RETURNING ... INTO` OUT variables from the column's neutral type alone, ignoring nullability, then assigned them to pointer fields — code that does not compile. Nullable numeric and temporal params now bind `sql.NullInt32`/`NullInt64`/`NullFloat64`/`NullTime`; string-like columns keep a plain OUT var and take its address, since godror documents `sql.NullString` as unsupported (Oracle cannot distinguish `''` from NULL)
2380
+ - `java-jdbc` and `kotlin-jdbc` read temporal columns with `rs.getObject(col, LocalDateTime.class)`, which snowflake-jdbc does not implement — its `getObject(int, Class<T>)` dispatches only on the legacy `java.sql` temporal types, so every `TIMESTAMP_NTZ` or `TIMESTAMP_TZ` read threw against real Snowflake. Snowflake now uses the legacy getters with null-safe conversion; the other eight JDBC engines are unchanged
2381
+ - Oracle schemas written as SQL\*Plus scripts failed to parse, freezing two integration projects at output an old build produced. The statement splitter only recognised `;`, but such scripts terminate on a lone `/` and contain no top-level semicolons; `CREATE SEQUENCE ... START WITH ... INCREMENT BY ...` is also rejected by the parser, and trigger bodies are PL/SQL it cannot read. Sequences and triggers contribute no columns and are now skipped, as `CREATE SCHEMA` already was
2382
+ - `validate_structural` knew 31 of the 52 registered backends; the other 21 reported "unknown backend" instead of being checked. Enrolling them surfaced two real defects: `python-oracledb`, `python-pyodbc` and `python-snowflake` emitted lines that violate ruff's line length for any query with a few columns, and `typescript-snowflake` emitted `any` for row and bind types
2383
+ - `scythe check` retained every analyzed query and verifiable block even when `--database-url` was absent, though both are only read when it is set
2384
+ - **CI's generated-code freshness gate had three holes that let real drift through unnoticed.** `integration_tests/Taskfile.yaml` hand-maintained a list of backends to regenerate that had drifted to 71 of the generator's own `build_backends()` 99 entries, so every Redshift, MSSQL and Snowflake backend was silently excluded and never regenerated by CI; the list now comes from a new `--list` flag on the generator instead of a hand-copied one. The gate also compared with `git diff --exit-code`, which cannot see untracked files, so a newly added backend with no committed output yet would pass green with nothing to regenerate against — it now uses `git status --porcelain`. And `scripts/check-generated-syntax.sh` printed `SKIPPED` and returned success whenever a language checker binary was missing, while the job that ran it installed no PHP, Ruby, Python or Go toolchain at all, so every one of those checks had been silently doing nothing since it was added. The script now fails on a missing checker in `--strict` mode (implied by `CI=true`), and the job installs all four toolchains. Regenerating the 29 backends the gate had never covered turned up no behavioral drift — 13 files changed, all formatting ([#72](https://github.com/Goldziher/scythe/issues/72))
2385
+ - Bare `FLOAT` (no precision) normalized incorrectly on two dialects, though not the defect [#73](https://github.com/Goldziher/scythe/issues/73) reported: the silent narrowing of `FLOAT(53)` it described does not exist, since `normalize_data_type` already maps any precision above 24 to `double precision` on every dialect. The real bugs were in the two unparameterized paths. The neutral-type resolver's bare `"float"` string arm defaulted to `float32` unconditionally, wrong on PostgreSQL, MSSQL and Oracle, where bare `FLOAT` is 8-byte double precision; and `DataType::Float(None)` — sqlparser's node for the same bare `FLOAT` — normalized to `double precision` for every dialect, wrong on MySQL, whose bare `FLOAT` is a genuine 4-byte type. Both paths are now dialect-aware: MySQL's bare `FLOAT` resolves to `float32`, every other dialect to `float64`
2386
+ - MySQL `UNSIGNED` integer columns (`INT UNSIGNED`, `BIGINT UNSIGNED`, etc.) failed codegen outright with `BackendError::UnknownType("bigint unsigned")` — a hard failure on an ordinary MySQL schema, not a silently wrong type. `normalize_data_type` preserved the MySQL display width (e.g. `"bigint(20) unsigned"`), which the neutral-type resolver had no matching arm for and which its `strip_precision` helper couldn't rescue, since the parenthesized width isn't trailing. The normalizer now discards the display width for every unsigned integer type, giving the resolver a clean string to match ([#74](https://github.com/Goldziher/scythe/issues/74))
2387
+ - `BIT` columns lost their declared width during normalization, collapsing `BIT(1)` and `BIT(n>1)` to the same bare `"bit"` string and making them indistinguishable downstream. The width is now preserved (`"bit(1)"`, `"bit(8)"`), so the neutral-type resolver can tell a boolean-ish `BIT(1)` from a genuine multi-bit value — which PostgreSQL treats as a bit string (`bytes`) and MySQL treats as an integer bitfield (`int64`). MSSQL's `BIT` is untouched: it has no width and was already correctly `bool`, and none of the 11 MSSQL integration harnesses changed when regenerated, which is the evidence the fix is scoped to PostgreSQL and MySQL ([#75](https://github.com/Goldziher/scythe/issues/75))
2388
+ - A scalar subquery's inferred type inherited only its projected column's own nullability, ignoring that the subquery itself evaluates to `NULL` when it matches zero rows: `(SELECT name FROM users WHERE id = $1)` was typed non-nullable whenever `users.name` was `NOT NULL`, even though the subquery is nullable by construction. It's now nullable unless the query is provably guaranteed to return exactly one row — an ungrouped aggregate — in which case the aggregate's own nullability already accounts for the empty-input case. That carve-out stops short of windowed aggregates: `COUNT(*) OVER ()` looks like a single-row aggregate but produces one output row per input row, so it stays subject to the general zero-rows-means-`NULL` rule ([#76](https://github.com/Goldziher/scythe/issues/76))
2389
+ - `WITH RECURSIVE` queries were typed from the anchor branch alone, discarding the recursive branch's analysis with `let _ = ...` — under-reporting nullability whenever the recursive term introduced a `NULL` the anchor didn't have, such as a `LEFT JOIN` or an explicit `NULL` literal filling a column the anchor fills with a `NOT NULL` value. The full anchor-UNION-recursive query is now re-analyzed and kept, taking the same `SetOperation` path as any other `UNION` — which also means a column-count mismatch between the anchor and recursive branches now surfaces as an error instead of being silently swallowed ([#77](https://github.com/Goldziher/scythe/issues/77))
2390
+ - SQLite integration harnesses are retyped to match the widened `int64`/`float64` neutral types from the dialect-aware fixes above. **`rust-sqlx-sqlite` had not compiled since `93b76b9`**, the earlier commit in this same release that widened SQLite `REAL` to `float64`: its harness template still declared `let total: f32`, so `order.total == total` could not type-check against the now-`f64` generated field. CI runs this suite on every push, so the job had been red since that commit landed; a concurrent GitHub Actions outage kept the failure from getting the scrutiny a red required job normally gets. `go-database-sql-sqlite` had the same defect from the `INTEGER` → `int64` change, failing with eight type errors because its harness declared `var createdUserID int32` while the generated code returned `int64`; its template grouped SQLite with MySQL, MSSQL and Snowflake, which legitimately use 32-bit ids, and SQLite now has its own arm. The remaining statically typed SQLite harnesses — C#, Java, Kotlin and the four TypeScript projects — were compile-checked and were already correct. Both fixed here
2391
+ - Every generated `Gemfile` declared no gem source, so all six Ruby integration projects failed to install. The same formatter pass had joined the magic comment and the source directive onto one line — `# frozen_string_literal: true source "https://rubygems.org"` — and since `#` opens a Ruby comment, the `source` call was silently commented out. The file stayed valid Ruby, which is why it survived: Bundler simply reported that gems were missing "in locally installed gems". CI additionally ran an older Bundler than the committed `Gemfile.lock` files were written with, which an older Bundler cannot read, so the Ruby steps now pin `bundler: latest`
2392
+ - Every generated `mix.exs` was a syntax error, failing six integration jobs before any Elixir test ran. Its template had been reflowed as prose and re-wrapped at 120 columns, putting the whole module on one line, which Elixir rejected at `mix.exs:1:63`. Formatting only — project name, version, `elixirc_paths` and every dependency are unchanged. Together with `pyproject.toml` below, this is the last functionally broken residue of that formatter pass; `composer.json` and `tsconfig.json` were reflowed by it too but remain valid, since JSON ignores whitespace
2393
+ - Five Kotlin projects had their generated file committed as `Queries.kt` while the generator writes `queries.kt`. On a case-insensitive filesystem those are one path, so generation overwrote in place and git never recorded the rename — meaning those projects shipped generated code that no current build produces, visible only on Linux. All nine Kotlin projects now use the generator's name. Java keeps `Queries.java`, which is correct, as Java requires the filename to match the public class
2394
+ - `go-godror-oracle` did not compile: its harness passed `int64` where the generated `CreateOrder` expects `float64`. Oracle's `NUMBER(10, 2)` is a scaled decimal and correctly maps to `float64`, so the harness was stale, not the type mapping
2395
+ - `go-gosnowflake` failed with missing `go.sum` entries across the driver's Azure, AWS and Arrow dependency tree. It was the only one of the eight Go integration steps not running `go mod tidy`, and since the generated `go.mod` carries direct dependencies only while Go 1.17+ module-graph pruning needs the indirect set resolved, that step could never have succeeded
2396
+ - Every generated Python integration project had an unparseable `pyproject.toml`. Its template's first line had been collapsed into `[project] name = "..." version = "..." requires-python = "..." dependencies = [`, which looks plausible but is invalid TOML, so `uv` failed with `TOML parse error at line 1, column 11` before running anything. This broke seven of the eight integration jobs — every one that touches a Python backend — and is unrepaired residue from the same formatter pass that reflowed the Jinja templates as prose in `d895d04`; the follow-up repair in `d4d6694` missed this file. The other two TOML templates were checked and are intact
2397
+ - **Manifest selection no longer depends on the process working directory.** At 56 call sites, one per backend constructor, manifest loading preferred a CWD-relative `backends/<name>/manifest.toml` over the compiled-in manifest, so identical inputs produced different generated code depending on where `scythe` was invoked, with nothing in the output recording which manifest was used. The lookup was also engine-blind: every `rust-sqlx` engine variant probed the same PostgreSQL file, and `java-jdbc` collapsed nine engines onto one path, so a MySQL or SQLite target run from a directory containing `backends/` would have silently received PostgreSQL type mappings. Manifests are now compiled in and selected purely from `(backend, engine)`. The lookup was undocumented — no CLI flag, no config key, no log line, discoverable only by reading the source — and fired in no integration project and no CI job; all 13 stub manifests were byte-identical to their compiled-in counterparts, so removing it changes no generated output. Note that this is the determinism half of [#82](https://github.com/Goldziher/scythe/issues/82) only: there is no user-facing manifest override yet, and the issue stays open for one, since a global override directory would reintroduce the engine collision above. Also corrects the MSSQL type-mapping docs, which claimed `TINYINT` maps to a nonexistent `int8` neutral type — it maps to `int16`
2398
+
2399
+ ### Changed
2400
+
2401
+ - **Breaking (output):** `scythe check` now writes its report to stdout instead of stderr, and no longer prints the trailing `Check passed.` line or the warnings-only summary. Scripts parsing either will need updating
2402
+ - **Breaking (types):** SQLite `REAL` and `INTEGER` columns now resolve to `float64` and `int64` instead of `float32` and `int32`. Both of SQLite's storage classes are 8 bytes wide with no narrower variant — `REAL` is defined as an 8-byte IEEE float, and `INTEGER` holds up to 8 bytes — but the type mapper applied PostgreSQL's 4-byte widths (`real`/`integer` genuinely are `float4`/`int4` there) to every engine. Statically typed SQLite targets change accordingly (`f32` → `f64`, `int32` → `int64`, `float`/`int`/`getFloat`/`getInt` → `double`/`long`/`getDouble`/`getLong`); because `INTEGER PRIMARY KEY` is SQLite's rowid alias, every SQLite primary key retypes along with it. PostgreSQL is unaffected ([#70](https://github.com/Goldziher/scythe/issues/70))
2403
+ - **Breaking (API):** generated Kysely functions now take `QueryExecutorProvider` rather than `Kysely<DB>`. The previous `<DB = any>` generic did nothing useful, and the narrower type rejected callers holding a connection or a controlled transaction — both of which Kysely's `RawBuilder.execute` accepts
2404
+ - The Snowflake `NUMBER(p, s)` normalizer now preserves precision and scale in `Catalog::Column::sql_type` (consumed by the `rust-sibyl` backend). This does **not** change inferred neutral types: `sql_type_to_neutral` strips precision before mapping, so `numeric(10,2)` and `numeric` resolve identically. The `int64` → `float64` shift visible in the Snowflake integration output came from regenerating stale committed files, not from this change. *(Supersedes an earlier entry in this section which credited this commit with fixing money-column truncation across all seven Snowflake projects — that truncation was a real bug, but it was fixed for Oracle in 0.11.0 and the Snowflake output was merely out of date.)*
2405
+ - `better-sqlite3` moves to `^12.11.1` in the integration projects, and the SQLite CI job to Node 24. `node:sqlite` is only unflagged from Node 23.4, and better-sqlite3 11.10 will not load on Node 24+
2406
+ - The documentation site migrated from zensical to Astro Starlight, which incidentally fixed `guide/audit` and `guide/inspect` being unreachable on the live site
2407
+ - fakesnow's shared query-request wrapper (moved to `integration_tests/fakesnow/fakesnow_server.py`, see Removed) now always emits the plain Snowflake JSON rowset format — every cell stringified, matching real Snowflake's wire format — instead of doing so only for the Node driver. Query execution is serialized with an `asyncio.Lock` so a client's HTTP retry cannot re-run a statement concurrently with the still-in-flight original. The login handler now advertises `CLIENT_RESULT_COLUMN_CASE_INSENSITIVE`, which snowflake-jdbc needs to resolve lowercase generated-code column lookups (`getInt("id")`) against fakesnow's uppercase column labels
2408
+ - `go-gosnowflake`'s generated harness pointed at `sql/snowflake/schema_emu.sql`, a leftover from an abandoned Docker-emulator plan that lacked `AUTOINCREMENT`; it now uses `sql/snowflake/schema.sql` like every other Snowflake backend
2409
+ - `elixir-tds-mssql` is back in CI — its step was added in `7b3ec72`, removed in `5edaaa6` while the backend was broken, and restored once the type mapping was fixed. Its `integration_tests/Taskfile.yaml` entry is new ([#28](https://github.com/Goldziher/scythe/issues/28))
2410
+
2411
+ ### Removed
2412
+
2413
+ - `integration_tests/typescript-snowflake/fakesnow_server.py` moved to `integration_tests/fakesnow/fakesnow_server.py` — it is shared infrastructure for every non-Python Snowflake driver, not a TypeScript-specific fixture
2414
+ - The root-level `backends/` directory (23 files): 13 manifests byte-identical to their compiled-in counterparts under `crates/scythe-codegen/manifests/`, plus 10 Jinja templates that no code path reads — a vestige of an abandoned template-based architecture, since every backend emits strings directly. It existed only to be picked up by the working-directory-relative manifest lookup removed above. `scythe-backend`'s renderer tests, the sole remaining reader, now use a fixture under `crates/scythe-backend/tests/fixtures/`
2415
+ - `naming.field_case` manifest option. It was deserialized from all 106 manifests and never read — field names come from `to_snake_case` in `resolve.rs` regardless of what's declared, so the 73 manifests declaring `camelCase` or `PascalCase` were silently ignored, while `fn_case` on those same manifests is honored, which is what made the gap easy to miss. Implementing it instead would rename fields in generated code for most backends and break every downstream caller that destructures a row, so the option is deleted rather than wired up — universal snake_case field naming is now intentional instead of accidental. Regenerating all 99 integration backends afterward produced no diff, which is the proof the option was dead ([#69](https://github.com/Goldziher/scythe/issues/69))
2416
+
2417
+ ### Unverified / Skipped in CI
2418
+
2419
+ These backends have codegen support but are not exercised against a live database. The equivalent
2420
+ list under [0.6.8] describes that release and is now out of date; this one supersedes it.
2421
+
2422
+ **Snowflake** ([#27](https://github.com/Goldziher/scythe/issues/27)) — `python-snowflake`,
2423
+ `typescript-snowflake`, `go-gosnowflake`, `java-jdbc-snowflake` and `kotlin-jdbc-snowflake` all run
2424
+ against the shared [fakesnow](https://github.com/tekumara/fakesnow) server. The two JDBC suites were
2425
+ unblocked this release by teaching fakesnow to serve snowflake-jdbc its native Arrow result format.
2426
+ Still excluded:
2427
+
2428
+ - `csharp-snowflake` — the codegen defect was fixed this release, but the harness fails earlier:
2429
+ Snowflake.Data names its bind parameters `p1`/`p2`/`p3`, which fakesnow's binding-name heuristic
2430
+ treats as named rather than positional. A fakesnow limitation, not a codegen one
2431
+ - `php-pdo-snowflake` — uncoverable. Snowflake has no PDO driver; access requires the proprietary
2432
+ closed-source ODBC driver preinstalled on the runner
2433
+
2434
+ **Oracle** — `elixir-jamdb` (`DBConnection.ConnectionPool` dispatch error with `jamdb_oracle`) and
2435
+ `ruby-oci8` (native gem needs Oracle Instant Client SDK headers unavailable in CI).
2436
+
2437
+ **SQLite** — `php-pdo-sqlite` has no CI job. The `createUser` arity mismatch noted under [0.6.8] is
2438
+ resolved (generated signature and harness call now agree, and the harness parses), but it has never
2439
+ been run against a database.
2440
+
2441
+ ## [0.11.0] - 2026-07-04
2442
+
2443
+ ### Added
2444
+
2445
+ - Full `:grouped` / `@group_by` nested code generation across every backend. A `:grouped` query now emits a child struct plus a parent struct carrying a `children` collection, and a query function that runs the flat SQL and folds rows into an order-preserving list of parents keyed by the grouping column — all client-side, with the SQL unchanged from `:many`. Previously `:grouped` silently degraded to a flat `:many` proxy despite the docs promising nesting (#55). Implemented for all Rust, Python, TypeScript, C#, Go, Ruby, PHP, Elixir, and Java/Kotlin backends, each with language-native structs, collection types, and fold idioms.
2446
+ - `CodegenBackend::generate_grouped_structs` and `generate_grouped_query_fn` trait methods (inputs bundled in a `GroupedQueryFn` context struct) with default implementations that return a clear "grouped queries are not yet supported by '<backend>'" error, so future backends opt in incrementally without panicking.
2447
+ - Positional param-naming escape hatch: `-- @param $N <name>[: <description>]` overrides the inferred/`pN` fallback name for a placeholder by position, flowing the chosen name to every language. The existing docs-only `-- @param <name>: <description>` form is unchanged (#53).
2448
+ - Lint rule SC-S07 `unbound-sql-param` (error): flags any `$N` present in the SQL body but absent from the generated parameter signature, backstopping the whole class of silent param drops.
2449
+
2450
+ ### Fixed
2451
+
2452
+ - Params inside a FROM-clause derived table (subquery) are no longer discarded — the sub-analyzer's collected params and positional counter are merged back into the parent scope (#52, Case C).
2453
+ - Placeholders nested inside an `UPDATE … SET` arithmetic expression such as `SET credits = credits + $2` are now collected instead of silently dropped; param collection recurses through `BinaryOp`/`UnaryOp`/`Nested` expressions (but not subqueries, which own their own param scope). Caught by SC-S07 (#52).
2454
+ - Unsupported inline named placeholders (`:name`) now fail fast with a query-pointed error instead of emitting broken codegen (#52, Cases A/B).
2455
+
2456
+ ### Changed
2457
+
2458
+ - Workspace crate versions bumped 0.10.0 → 0.11.0 across all six crates, with cross-crate path-dep version pins updated.
2459
+ - `sqruff-lib` upgraded 0.38 → 0.39 (`cargo upgrade --incompatible`); lockfile refreshed.
2460
+
2461
+ ## [0.10.0] - 2026-06-14
2462
+
2463
+ ### Added
2464
+
2465
+ - `scythe inspect <database-url>` subcommand — live-database operational health checks. Connects via `tokio-postgres` and runs a set of `pg_catalog` queries that detect issues only visible in a running database, then emits findings in the same human / SARIF 2.1.0 / JSON reporter shapes used by `scythe audit`. URL resolution: positional argument, then `$DATABASE_URL`, then `$SCYTHE_DATABASE_URL`. Builds a per-invocation `tokio::runtime::Builder::new_current_thread()` runtime so the rest of the CLI (`lint`, `audit`, `generate`) stays synchronous.
2466
+ - New `scythe-inspect` crate (`crates/scythe-inspect/`) carrying a `DbDriver` async trait, a `PostgresDriver` implementation backed by `tokio-postgres`, and a `MysqlDriver` stub that returns `InspectError::Unsupported("mysql")` from `connect` and `run_all`. The stub exists to keep the trait shape engine-agnostic; a real MySQL driver lands in Phase 3 (v0.13.0).
2467
+ - Three Postgres operational checks at Phase 0, clean-room reimplemented from the equivalent supabase/splinter lints (no source code copied; ATTRIBUTIONS.md updated): SC-INS01 missing-fk-index (warn — foreign-key columns with no covering index force a sequential scan on every join through the constraint; splinter 0001), SC-INS02 policy-exists-rls-disabled (error — table has `CREATE POLICY` definitions but `ROW LEVEL SECURITY` is disabled, so the policies never apply; splinter 0006), and SC-INS03 duplicate-index (warn — two or more indexes with identical definitions modulo name; splinter 0009).
2468
+ - `scythe inspect --list-checks` prints the check catalog (id, name, severity, description) without connecting, so users can discover the rule set offline.
2469
+ - `scythe inspect --format <human|sarif|json>`, `--severity <off|warn|error>`, `--exit-zero`, `--output <PATH>`, `--dialect <postgres|mysql>` — mirror the audit subcommand surface for consistency. Exit code 2 on remaining error-severity findings unless `--exit-zero` is set; exit 0 otherwise. Severity floor filtering applies before emission.
2470
+ - Public `scythe-inspect` pre-commit hook published via `.pre-commit-hooks.yaml`. CI-mode hook: `always_run: true`, `pass_filenames: false`, requires `$DATABASE_URL` (or `$SCYTHE_DATABASE_URL`) in the hook environment. Local pre-commit runs without the variable fail loudly with the same error as the CLI. Phase 1 (v0.11.0) will add `scythe.toml` `[inspect]` URL sourcing so local use becomes natural.
2471
+ - New documentation page `docs/guide/inspect.md` covering quick-start, check catalog, severity/exit-code semantics, GitHub Actions CI recipe with `services: postgres`, pre-commit usage, what `scythe inspect` does not do (yet), and the phased roadmap through v0.14.0.
2472
+ - `docs/guide/cli-reference.md` extended with the `inspect` subcommand and every flag; `docs/guide/pre-commit-hooks.md` adds the new `scythe-inspect` hook row and section; README adds `scythe inspect` to the feature list and a Documentation link.
2473
+ - New CI workflow `.github/workflows/inspect-live.yml` spins up `postgres:16-alpine` as a service and runs `cargo test -p scythe-inspect --features live-tests`. Triggered on PRs that touch `crates/scythe-inspect/**`. Default `cargo test` runs stay DB-free.
2474
+ - `ATTRIBUTIONS.md` extended with a "Live inspection rules inspired by splinter (scythe-inspect)" subsection citing splinter lints 0001, 0006, 0009 against SC-INS01, SC-INS02, SC-INS03 respectively.
2475
+
2476
+ ### Changed
2477
+
2478
+ - Workspace crate versions bumped 0.9.0 → 0.10.0 across all six crates (the five existing crates plus the new `scythe-inspect`), with cross-crate path-dep version pins updated.
2479
+ - `scythe lint` and `scythe audit` are unaffected — Phase 0 adds the inspect surface without touching the static pipeline.
2480
+
2481
+ ## [0.9.0] - 2026-06-14
2482
+
2483
+ ### Added
2484
+
2485
+ - `scythe audit` subcommand — static security analyzer for SQL. Reads `.sql` files, runs a built-in security rule pack, and emits findings as human-readable text, SARIF 2.1.0 (with CWE tags for code-scanning ingest), or JSON. Exits non-zero when any rule fires, so it slots into CI gates.
2486
+ - `scythe audit --list-rules` — print the rule catalog (id, name, severity, category, description) grouped by category, then exit 0. Reflects user-loaded rules from `scythe.toml` so the catalog is honest.
2487
+ - `scythe audit --explain <RULE_ID>` — print the description and CWE references for a rule by id, then exit 0. Useful for figuring out why a rule fired without going to the docs.
2488
+ - `scythe audit --severity <off|warn|error>` — drop findings below the given level so CI gates can graduate from warnings to errors.
2489
+ - `scythe audit --exit-zero` — always exit 0 after emitting findings, for advisory CI integrations that publish findings but don't gate the build.
2490
+ - `scythe audit -o, --output <PATH>` — write reporter output to a file instead of stdout. Useful for SARIF/JSON artifacts in CI.
2491
+ - `scythe audit --ignore-suppressions` — disable inline `-- scythe-audit: ignore[...]` annotations for periodic strict scans.
2492
+ - `scythe audit --dialect <postgres|mysql|sqlite|mssql|oracle|snowflake>` — set the SQL dialect for explicit-file mode (config mode already inherits the dialect from `[[sql]].engine`).
2493
+ - New docs page `docs/guide/audit.md` covering quick-start, rule catalog, suppression syntax, user-defined rules, available matchers, and CI integration recipes (GitHub Actions SARIF, GitLab SAST, pre-commit). `docs/guide/cli-reference.md` extended with the `audit` subcommand and every flag.
2494
+ - `Severity` now derives `PartialOrd`/`Ord` and gains a `Severity::parse_cli` helper so CLI consumers can resolve `off`/`warn`/`error` to a typed minimum.
2495
+ - Eleven canonical security rules ship in `scythe-lint`'s `audit` module: SC-SEC01 dangerous-function (CWE-78), SC-SEC02 grant-all (CWE-269), SC-SEC03 grant-to-public (CWE-269), SC-SEC04 superuser-role (CWE-269) covering SUPERUSER/CREATEDB/CREATEROLE/REPLICATION/BYPASSRLS, SC-SEC05 literal-password (CWE-798), SC-SEC06 weak-hash-in-auth (CWE-327, CWE-916), SC-SEC07 select-star-pii (CWE-200), SC-SEC08 cartesian-join (CWE-400), SC-SEC09 unbounded-like (CWE-1333), SC-SEC10 security-definer-no-search-path (CWE-426), and SC-SEC11 session-mutation (CWE-269) covering SET ROLE / SET SESSION AUTHORIZATION / RESET ROLE.
2496
+ - Hybrid matcher framework: rule metadata lives in TOML, AST-matching logic lives in named Rust functions registered against a `MatcherRegistry`. Adding a rule that reuses an existing matcher is now a TOML stanza, not a Rust file. Canonical rules ship in-tree via `include_str!` so the default registry has zero runtime config dependencies.
2497
+ - User-defined audit rules via `scythe.toml`: `[[audit.rule]]` for inline rules and `extra_rules = ["./path.toml"]` to load separate files. IDs must start with `USER-`; collisions with canonical `SC-SEC*` IDs are rejected at load time with the offending ID and source path.
2498
+ - Inline suppressions: `-- scythe-audit: ignore[SC-SEC02,SC-SEC09] reason="vetted"` attaches to the next statement and suppresses the listed rule IDs for every line of that statement (terminated by a blank line or `;`). Reason clauses are parsed and discarded. Malformed annotations are silently ignored.
2499
+ - `LintContext.dialect: SqlDialect` field, threaded through every rule call site, so matchers can dialect-filter via `dialects = [...]` in the rule spec.
2500
+ - `RuleFile` TOML schema with `schema_version = 1` for forward-compatible rule files.
2501
+ - New `migration` rule category and nine canonical migration-safety rules under the `SC-MIG*` prefix: SC-MIG01 ban-drop-table, SC-MIG02 ban-drop-column, SC-MIG03 require-concurrent-index-creation, SC-MIG04 renaming-column, SC-MIG05 constraint-missing-not-valid, SC-MIG06 ban-drop-database-or-schema, SC-MIG07 renaming-table, SC-MIG08 ban-truncate-cascade, SC-MIG09 ban-alter-column-type. Each rule targets a class of irreversible or lock-prone Postgres DDL change that breaks zero-downtime deployments. All declare `dialects = ["postgres"]`. Seven matcher functions back them: `drop_statement` (parameterised by `kinds = ["table", "column", "database", "schema"]` so a single matcher serves SC-MIG01/SC-MIG02/SC-MIG06), `create_index_concurrency`, `alter_table_rename_column`, `constraint_missing_not_valid`, `alter_table_rename_table`, `truncate_cascade`, `alter_column_type`. The matcher framework is unchanged.
2502
+ - Four additional column-type-preference migration rules backed by a single new `column_type_disallowed` matcher: SC-MIG10 prefer-bigint-over-int (fires on `int`/`integer`/`int4`/`smallint`/`int2` — 32-bit keys overflow at 2^31 and widening requires a write-blocking ALTER), SC-MIG11 prefer-text-over-varchar (fires on `varchar(n)`/`character varying(n)`/`char(n)` — Postgres stores these identically to `text`; a length bump is write-blocking), SC-MIG12 prefer-timestamptz (fires on `timestamp`/`timestamp without time zone` — naive timestamps silently shift on session timezone changes), SC-MIG13 prefer-identity-over-serial (fires on `serial`/`bigserial`/`smallserial` — SERIAL is legacy implicit-sequence shorthand; `GENERATED AS IDENTITY` is the SQL-standard replacement). The matcher walks `CREATE TABLE` columns and `ALTER TABLE … ADD COLUMN` operations, using exact-match and prefix-before-`(` semantics to avoid false-positives (e.g. `bigint` does not fire when `int` is disallowed). Emits `table`, `column`, `actual_type`, and `suggested_type` bindings.
2503
+ - The `scythe audit` dispatcher now also runs rules in the new `migration` category; `--list-rules` groups SC-MIG* under a separate `[migration]` heading.
2504
+ - Three additional constraint-lock migration rules covering the next class of Squawk-derived ALTER hazards: SC-MIG14 disallowed-unique-constraint (fires on `ALTER TABLE … ADD CONSTRAINT … UNIQUE (…)` — builds the index inline under ACCESS EXCLUSIVE; safe pattern is `CREATE UNIQUE INDEX CONCURRENTLY` followed by `ADD CONSTRAINT … UNIQUE USING INDEX`), SC-MIG15 adding-primary-key-constraint (fires on `ALTER TABLE … ADD CONSTRAINT … PRIMARY KEY (…)` — same lock hazard, same `USING INDEX` workaround), SC-MIG16 ban-create-domain-with-constraint (fires on `CREATE DOMAIN … CHECK (…)` — Postgres validates every row of every table using the domain under ACCESS EXCLUSIVE and the constraint cannot be split into `NOT VALID` + `VALIDATE`). Two new matchers back them: `add_constraint_without_using_index` (parameterised by `kinds = ["unique", "primary_key"]` so a single matcher serves SC-MIG14/SC-MIG15, and distinguishes the plain `UNIQUE`/`PRIMARY KEY` table constraints from the `… USING INDEX` variants) and `create_domain_with_constraint`.
2505
+ - Two NULL-contract-integrity migration rules: SC-MIG17 ban-drop-not-null (error — fires on `ALTER TABLE … ALTER COLUMN … DROP NOT NULL`; relaxing a NOT NULL contract breaks deployed application versions and ORM mappings that still treat the column as non-null) and SC-MIG18 adding-not-nullable-field (warn — fires on `ALTER TABLE … ADD COLUMN … NOT NULL` without a `DEFAULT`; rewrites every existing row on Postgres <11 and breaks deployed application versions that insert without the new column). Two new matchers back them: `alter_column_drop_not_null` and `add_column_not_null_no_default`. Both rules declare `dialects = ["postgres"]`.
2506
+ - Two splinter-inspired rules covering function search-path hygiene and pg_upgrade-blocking column types: SC-SEC12 function-search-path-mutable (warn — fires on `CREATE FUNCTION` without `SET search_path = …` and not `SECURITY DEFINER`; complementary to SC-SEC10 which owns the escalating DEFINER case at error severity, so the two rules never double-count on the same statement) and SC-MIG19 unsupported-reg-types (error — fires when a column type is `regcollation`/`regconfig`/`regdictionary`/`regnamespace`/`regoper`/`regoperator`/`regproc`/`regprocedure`; reg* OID types other than `regclass` block `pg_upgrade` and do not survive logical dump/restore). One new matcher (`function_search_path_mutable`); SC-MIG19 reuses the existing `column_type_disallowed` matcher with an empty `suggested` and a regtype `disallowed` list. Detection patterns inspired by supabase/splinter lints 0011 and 0018 — see `ATTRIBUTIONS.md`.
2507
+ - `ATTRIBUTIONS.md` at the repo root listing external projects whose detection patterns informed scythe rules. Initial entry credits supabase/splinter and documents the no-license caveat (clean-room reimplementation only).
2508
+ - Row Level Security rule pack — three rules under the new `SC-RLS*` prefix (still `category = "security"`): SC-RLS01 policy-references-user-metadata (error, CWE-639 — fires on `CREATE POLICY` whose USING or WITH CHECK reads from `user_metadata`, an end-user-editable JWT claim; safe path uses server-set `app_metadata`), SC-RLS02 policy-always-permissive (error, CWE-285 — fires on a permissive policy whose USING or WITH CHECK is a tautology like `(true)`, `(1 = 1)`, or `NULL` on a write-side command; SELECT policies and restrictive policies are excluded), SC-RLS03 policy-uses-uncached-auth-function (warn, CWE-405 — fires on a bare `auth.uid()` / `auth.jwt()` / `auth.role()` / `auth.email()` / `current_setting(…)` call in the policy expression without wrapping in a scalar subquery; wrapping lets Postgres cache the result as an InitPlan instead of re-evaluating per row). Three new matchers walk the typed `CreatePolicy.using` / `.with_check` `Expr` ASTs. SC-RLS03 specifically stops at `Expr::Subquery` boundaries — that's the safe form. Detection patterns inspired by supabase/splinter lints 0015, 0024, 0003 — see `ATTRIBUTIONS.md`.
2509
+ - CHECK-constraint quality rule SC-CHK01 check-constraint-always-true (warn, `category = "antipattern"`): fires when a CHECK constraint expression is a tautology (`true`, `1 = 1`, `NULL`, parenthesised variants). Covers column-level CHECK in `CREATE TABLE`, table-level CHECK in `CREATE TABLE`, and `ALTER TABLE … ADD CONSTRAINT … CHECK`. A tautological CHECK enforces nothing — almost always signals a copy-paste mistake or unfinished migration. New matcher `check_constraint_always_true`. New canonical TOML file `rules/quality.toml` carrying the `SC-CHK*` rule namespace.
2510
+ - `scythe audit` now dispatches rules in the `Antipattern` category alongside `Security` and `Migration`, so non-security canonical rules surface in audit output. `--list-rules` groups SC-CHK* under a separate `[antipattern]` heading.
2511
+ - `scythe lint` now runs the canonical SC-SEC*, SC-RLS*, SC-MIG*, and SC-CHK* audit packs alongside the existing schema-aware safety/codegen/naming rules and sqruff. Dialect gating: rules whose `dialects` list excludes the configured `[[sql]].engine` are silently skipped, so a `mysql` project does not see postgres-only `SC-MIG*` findings without explicit opt-in. No CLI flag is required — the rules ship in `default_registry()` and respect the same `[lint]` severity overrides as the rest of the rule set.
2512
+ - Public `scythe-audit` pre-commit hook published via `.pre-commit-hooks.yaml`. Runs the canonical audit rule packs over staged `.sql` files with no `scythe.toml` required. Defaults to the postgres dialect; override per-hook via `args: [--dialect, mysql]`. The existing `scythe-lint` hook now also picks up audit rules whenever a `scythe.toml` is present. Documented in `docs/guide/pre-commit-hooks.md` and `docs/guide/audit.md`.
2513
+ - Oracle bindings upgraded to sibyl 0.7. The codegen emitter (`crates/scythe-codegen/src/backends/rust_sibyl.rs`) was rewritten for sibyl 0.7's broken APIs: `sibyl::prelude` is gone (top-level re-exports used directly), `Varchar::as_str()` now returns `&str` instead of `Result<&str>`, and `Date::timestamp()` was removed (chrono::NaiveDateTime now built from the `date_and_time()` tuple). The integration test template selects `["tokio", "nonblocking"]`; without `nonblocking`, sibyl 0.7's `impl Debug for LOB` has every `fn fmt` body cfg-gated away and the lib fails to build. The Oracle manifest now maps `decimal` to `f64` because sibyl 0.7 has no `ToSql`/`FromSql` for `rust_decimal::Decimal` — flagged as a precision trade-off for follow-up.
2514
+ - sqlx 0.8 → 0.9 in the Rust integration test crates (`rust-sqlx`, `rust-sqlx-mysql`, `rust-sqlx-mariadb`, `rust-sqlx-sqlite`, `rust-sqlx-redshift`). sqlx 0.9 tightened `raw_sql` and `query` to require `SqlSafeStr`; the integration test template now wraps runtime SQL strings with `sqlx::AssertSqlSafe`.
2515
+
2516
+ ### Fixed
2517
+
2518
+ - Five `test_engines` codegen tests that were failing on `main` against the previous baseline are green. Three were neutral-type mappings falling through to the unknown-type literal fallback: MSSQL `DATETIMEOFFSET` → `datetime_tz` (was `"datetimeoffset"`), Redshift `SUPER` → `json` (was `"super"`), Oracle `NUMBER(p, s)` with a non-zero scale → `decimal` (was `int64` because `normalize_data_type` was ignoring the `Custom`-token scale parameter). Two were stale fixture expectations: Oracle `NUMBER(10)` correctly maps to `int64` (10 digits overflows int32), and Snowflake `INTEGER` correctly maps to `int32` (sqlparser parses it dialect-agnostically as `DataType::Integer(None)`; dialect-aware widening to int64 is tracked as a separate follow-up).
2519
+
2520
+ ### Changed
2521
+
2522
+ - The four Postgres-specific audit rules (SC-SEC04 superuser-role, SC-SEC05 literal-password, SC-SEC10 security-definer-no-search-path, SC-SEC11 session-mutation) now declare `dialects = ["postgres"]` and no-op on non-PostgreSQL dialects instead of producing false positives. Behaviour is unchanged for the default PostgreSQL workflow.
2523
+ - Pre-commit hook chain aligned with the polyrepo's shared `kreuzberg-dev/pre-commit-hooks v2.1.10` source. Nine individual hook repos collapsed into a single consolidated source for general file checks, markdown, Rust (fmt/clippy/sort/machete/deny), shell (shfmt/shellcheck), typos, and ai-rulez governance. `taplo-format` and `biome-format` stay as separate repos. `rustdoc-lint`, `markdownlint-rumdl-strict`, and `rust-max-lines` are listed in the config but commented out with TODOs — scythe's current codebase trips each one (~449 missing-doc errors, 35 long-line markdown files, 4 source files over 1,000 LOC); each is its own focused remediation. A new `_typos.toml` allowlists SQL aliases (`ba`), a singularize edge case (`statu`), the typos default dictionary's surprise prefix entries (`CHEC`→`CHECK`, `SELEC`→`SELECT`) that fire on plural SQL keywords, and excludes lockfiles where hex commit hashes routinely trip false matches.
2524
+ - Sibyl-driven Oracle integration test now reads `schema.sql` instead of `schema_full.sql`. `schema_full.sql` contained PL/SQL `CREATE SEQUENCE … INCREMENT BY …` blocks that sqlparser cannot parse; the trimmed `schema.sql` carries only the `CREATE TABLE` DDL scythe actually needs for type inference. The test database setup still uses `schema_full.sql` separately.
2525
+
2526
+ ## [0.8.0] - 2026-05-26
2527
+
2528
+ ### Added
2529
+
2530
+ - Kotlin `extension_functions` backend option (opt-in, default off) for `kotlin-jdbc` and `kotlin-r2dbc`. When enabled, query functions are generated as idiomatic Kotlin extension functions on the connection receiver (`fun Connection.getUser(id: Int)` called as `connection.getUser(id)`) with expression bodies for value-returning queries. `kotlin-r2dbc` is reworked into a `suspend` extension on `io.r2dbc.spi.Connection`, moving the connection lifecycle to the caller. (#43)
2531
+ - PHP `namespace` backend option for `php-pdo` and `php-amphp`. Any value emits `namespace <value>;`; an empty string omits the declaration. Default remains `App\Generated`, so existing output is unchanged. Enables PSR-4 framework integration (Laravel, Symfony, etc.). (#46)
2532
+
2533
+ ### Fixed
2534
+
2535
+ - Schema parser no longer crashes on psql client meta-commands. `pg_dump 18+` and `dbmate` emit `\restrict` / `\unrestrict` lines that are not SQL; scythe now strips any line whose first non-whitespace character is `\` before parsing, so plain-format Postgres 18 dumps are consumed as-is. (#49)
2536
+ - `python-psycopg3`, `python-asyncpg`, and `python-aiomysql` now emit `import uuid` and `from typing import Any` when their type mappings use `uuid.UUID` / `dict[str, Any]`. Generated modules previously raised `NameError` on import. (#48)
2537
+
2538
+ ## [0.7.0] - 2026-05-20
2539
+
2540
+ ### Added
2541
+
2542
+ - `scythe-core` now captures unknown `-- @<name> <value>` annotation lines as `CustomAnnotation { name, value, line }` triples on `Annotations.custom` and `AnalyzedQuery.custom`. Lets crate consumers layer their own annotation vocabularies (e.g. HTTP routing metadata) on top of scythe without coupling the SQL compiler to any one domain. Native annotations (`@name`, `@returns`, `@param`, `@nullable`, `@nonnull`, `@json`, `@optional`, `@group_by`, `@deprecated`) are unaffected — only previously-ignored unknowns are captured.
2543
+ - `scythe-core` gained an optional `serde` feature that adds `Serialize` / `Deserialize` derives to the public IR types (`AnalyzedQuery`, `AnalyzedColumn`, `AnalyzedParam`, `EnumInfo`, `CompositeInfo`, `CompositeFieldInfo`, `GroupByConfig`, `QueryCommand`, `Annotations`, `ParamDoc`, `JsonMapping`, `CustomAnnotation`). Off by default.
2544
+ - `Catalog::tables_iter()` accessor returning `(&String, &Table)` pairs, complementing the existing `tables()` (which returns names only).
2545
+
2546
+ ### Fixed
2547
+
2548
+ - sqlparser 0.62 compatibility: handle multi-alias select items, object-name insert targets, and unsupported table-query insert targets so `cargo clippy --workspace -- -D warnings` is clean.
2549
+
2550
+ ## [0.6.13] - 2026-05-10
2551
+
2552
+ ### Fixed
2553
+
2554
+ - Generated Rust code is now rustfmt-clean — scythe invokes rustfmt on generated `.rs` files to ensure long function signatures are properly formatted across multiple lines, eliminating unnecessary diffs when downstream projects run `cargo fmt`
2555
+
2556
+ ## [0.6.12] - 2026-05-07
2557
+
2558
+ ### Fixed
2559
+
2560
+ - The 0.6.11 ON CONFLICT preprocessor scanned the raw SQL byte string, so text inside `--` line comments and `'…'` literals could trigger the predicate-stripping path and chew into the surrounding INSERT body. The scanner now runs against an ASCII-uppercase mask where comments + string literals are replaced with same-length spaces, so positions still line up but only structural SQL is matched.
2561
+
2562
+ ## [0.6.11] - 2026-05-07
2563
+
2564
+ ### Fixed
2565
+
2566
+ - PostgreSQL: accept `INSERT … ON CONFLICT (cols) WHERE … DO …` (the index-inference form for partial unique indexes). sqlparser-rs through 0.61 doesn't recognise the predicate, so scythe now strips it for the parser pass while keeping the original SQL for codegen and runtime, where Postgres validates and uses the predicate to pick the matching partial index. Mirrors the existing dialect-preprocess pattern used for Oracle and MSSQL.
2567
+
2568
+ ## [0.6.10] - 2026-05-06
2569
+
2570
+ ### Fixed
2571
+
2572
+ - Clippy warnings in `scythe-lint` style rules (`collapsible_match`) and `typescript-postgres` backend (`unnecessary_sort_by`)
2573
+
2574
+ ### Changed
2575
+
2576
+ - Fixture data for pending engines (MSSQL, Oracle, Redshift, Snowflake) moved from `engines_pending/` to `testing_data/engines_pending/` — all fixtures now under one directory
2577
+ - Updated pre-commit hooks: ai-rulez v4.1.6, rumdl v0.1.88, cargo-sort v2.1.4
2578
+ - Bumped integration test dependencies: `rand` 0.8.5 → 0.8.6, `pgx/v5` 5.7.4 → 5.9.2, `gosnowflake` 1.10.1 → 1.13.3, `snowflake-sdk` 1.15.0 → 2.0.4, `snowflake-jdbc` 3.16.1 → 4.0.2
2579
+
2580
+ ## [0.6.9] - 2026-04-15
2581
+
2582
+ ### Fixed
2583
+
2584
+ - `scythe fmt` and `scythe lint` now auto-detect SQL dialect from `scythe.toml` when files are passed directly (e.g. by pre-commit hooks)
2585
+ - PHP amphp: autoload vendor deps, use `query()` instead of `exec()`
2586
+ - Ruby SQLite: handle `:exec` CreateUser/CreateOrder with post-insert fetch
2587
+ - PHP SQLite: pass `status` param to `createUser`
2588
+ - Oracle CI: install Instant Client SDK headers for ruby-oci8
2589
+ - Snowflake CI: simplified to Python fakesnow only (no Docker emulator)
2590
+ - Kotlin SQLite: Float literal types for total values
2591
+ - Elixir jamdb Oracle: use `DBConnection.execute` and `schema_full.sql`
2592
+ - Elixir Ecto: use Postgrex directly, fix `:one` empty result handling
2593
+ - MariaDB C#: `GetValue().ToString()` for UUID columns (was `GetString()`)
2594
+ - Oracle Go: EZ Connect format (`//host:port/service`) for godror
2595
+
2596
+ ## [0.6.8] - 2026-04-15
2597
+
2598
+ ### Added
2599
+
2600
+ - MSSQL integration tests across 10 backends (Rust tiberius, Python pyodbc, Go go-mssqldb, TypeScript mssql, Java JDBC, Kotlin JDBC, C# SqlClient, Elixir TDS, Ruby TinyTds, PHP PDO)
2601
+ - Redshift integration tests across 13 backends (all PostgreSQL-compatible drivers with Redshift-specific manifests)
2602
+ - Snowflake integration tests across 7 backends (Python, TypeScript, Go, Java, Kotlin, C#, PHP)
2603
+ - MSSQL CI job with SQL Server 2022 Docker
2604
+ - Redshift CI job using PostgreSQL container with PG-compatible schema
2605
+ - Snowflake CI job with snowflake-emulator Docker + fakesnow for Python
2606
+ - MSSQL `OUTPUT INSERTED` preprocessing: converts to `RETURNING` for parser, preserves original SQL in codegen
2607
+ - Redshift `IDENTITY(N,N)` schema preprocessing: strips before parsing
2608
+ - Snowflake type mappings: `TIMESTAMP_NTZ`, `TIMESTAMP_TZ`, `TIMESTAMP_LTZ`, `VARIANT`
2609
+ - 89 total integration test backends (up from 69)
2610
+
2611
+ ### Fixed
2612
+
2613
+ - CI: `libaio1` → `libaio1t64` for Ubuntu 24.04 (Oracle job)
2614
+ - CI: SQLite `create_if_missing(true)` + `touch` step
2615
+ - CI: removed committed macOS `.bundle/config`
2616
+ - Go codegen: `@pN` placeholder rewriting for MSSQL
2617
+ - Rust tiberius codegen: `Compat<TcpStream>` type, `&dyn ToSql` param binding, string `FromSql` handling
2618
+ - Ruby TinyTds codegen: type-aware param escaping (integers/booleans not escaped)
2619
+ - TypeScript mssql codegen: explicit `sql.*` type bindings for params
2620
+ - Template fixes for Redshift (no enums, `schema_pg_compat.sql`, status as string)
2621
+ - Elixir: `elixirc_paths` includes `generated/` for all backends
2622
+ - TypeScript: `String()` coercion for decimal total comparisons
2623
+
2624
+ ### Unverified / Skipped in CI
2625
+
2626
+ The following backends have codegen support but are **not tested in CI** due to driver/infra limitations:
2627
+
2628
+ **MSSQL:**
2629
+
2630
+ - `elixir-tds` — Elixir `tds` library parameter type encoding fails ([#28](https://github.com/Goldziher/scythe/issues/28))
2631
+
2632
+ **Oracle:**
2633
+
2634
+ - `elixir-jamdb` — `DBConnection.ConnectionPool` dispatch error with `jamdb_oracle`
2635
+ - `ruby-oci8` — native gem requires Oracle Instant Client SDK headers not available in CI
2636
+
2637
+ **SQLite:**
2638
+
2639
+ - `php-pdo-sqlite` — generated `createUser` param count mismatch with test template
2640
+
2641
+ **Snowflake** ([#27](https://github.com/Goldziher/scythe/issues/27)):
2642
+
2643
+ `python-snowflake`, `typescript-snowflake`, and `go-gosnowflake` all run in CI against a shared
2644
+ [fakesnow](https://github.com/tekumara/fakesnow) server
2645
+ (`integration_tests/fakesnow/fakesnow_server.py`) — gosnowflake connects with `protocol=http&insecureMode=true`
2646
+ to skip TLS/OCSP the same way the Node driver does. The remaining three are still excluded:
2647
+
2648
+ - `java-jdbc-snowflake` / `kotlin-jdbc-snowflake` — both use the snowflake-jdbc driver, which fakesnow forces
2649
+ into its JSON result format (fakesnow has no Arrow chunk-download endpoint). snowflake-jdbc's JSON-format
2650
+ `ResultSet` doesn't implement `getObject(int, LocalDateTime.class)`, so any query touching a `TIMESTAMP_NTZ`
2651
+ column throws regardless of how the connection is configured. Enabling these needs an Arrow chunk-download
2652
+ endpoint in `fakesnow_server.py`; the JDBC-side wiring (insecure TLS URL parameters) was deliberately not
2653
+ landed, since it can't be verified end to end until that blocker is lifted.
2654
+ - `csharp-snowflake` — not attempted. The Snowflake.Data driver needs its own TLS/OCSP and result-format
2655
+ investigation, which was not carried out, so no claim is made either way about whether it can work.
2656
+ - `php-pdo-snowflake` — genuinely uncoverable in CI: `composer.json` only declares `ext-pdo_odbc`, and the
2657
+ proprietary `pdo_snowflake` PHP extension isn't installable through Composer, PECL, or any standard CI
2658
+ package manager. It requires Snowflake's closed-source ODBC driver preinstalled on the runner.
2659
+
2660
+ ## [0.6.7] - 2026-04-12
2661
+
2662
+ ### Added
2663
+
2664
+ - Oracle integration tests across 9 backends (Python oracledb, TypeScript oracledb, Go godror, Java JDBC, Kotlin JDBC, C# Oracle, Elixir jamdb, Ruby oci8, Rust sibyl)
2665
+ - Oracle CI job with Oracle XE 21 and Instant Client
2666
+ - Oracle SQL support: `:N` placeholder preprocessing, `RETURNING ... INTO` output bind codegen
2667
+ - Oracle `orders.sql` queries with `RETURNING INTO` support
2668
+ - `structs_only` option for Rust sqlx backend (skips `sqlx::query!()` macros that require compile-time DB)
2669
+
2670
+ ### Changed
2671
+
2672
+ - Java codegen: emit `package generated;` and `public class Queries { ... }` wrapper — eliminates hand-written wrapper files
2673
+ - Kotlin codegen: emit `package generated` header
2674
+ - Java output path: `src/main/java/generated/Queries.java`; Kotlin: `src/main/kotlin/generated/queries.kt`
2675
+ - Rust sqlx integration tests output to `src/queries.rs` with `structs_only` mode
2676
+ - Oracle dialect uses `OracleDialect` from sqlparser (was `GenericDialect`)
2677
+
2678
+ ### Fixed
2679
+
2680
+ - Go database-sql MySQL: fixed connection failure when `MYSQL_URL` uses `mysql://` URL format
2681
+ - Ruby mysql2 MySQL: regenerated code to use `stmt.affected_rows` (fixes incorrect `DELETE` row counts)
2682
+ - Java/Kotlin JDBC: enum columns read via `valueOf(toUpperCase())` instead of broken `getObject()`
2683
+ - Java/Kotlin JDBC: PostgreSQL enum params use `setObject(Types.OTHER)`, others use `setString(getValue())`
2684
+ - Java/Kotlin JDBC MariaDB: `RETURNING` queries use `execute()` + `getResultSet()` (MySQL Connector/J doesn't support `executeQuery()` for DML RETURNING)
2685
+ - Rust sqlx MariaDB: UUID columns cast to `CHAR` in all queries (sqlx can't decode MariaDB BINARY UUID)
2686
+ - Rust sqlx MariaDB/MySQL: use `last_insert_id()` from result instead of `LAST_INSERT_ID()` SQL function (pool connection mismatch)
2687
+ - Rust sqlx: `raw_sql()` for multi-statement schema loading (PG and SQLite)
2688
+ - MariaDB manifests: UUID mapped to `String` for Rust sqlx, Java JDBC, Kotlin JDBC (drivers return String, not UUID object)
2689
+ - Java imports: `java.time.*` wildcard for all temporal types
2690
+
2691
+ ## [0.6.6] - 2026-04-12
2692
+
2693
+ ### Added
2694
+
2695
+ - MariaDB integration tests across all 11 supported backends (Rust sqlx, Python aiomysql, TypeScript mysql2, Go database/sql, Java JDBC, Kotlin JDBC, C# MySqlConnector, Elixir MyXQL, Ruby mysql2, Ruby trilogy, PHP PDO)
2696
+ - MariaDB CI job running all 11 backends against MariaDB 11
2697
+ - MariaDB `orders.sql` queries with `INSERT...RETURNING` support
2698
+
2699
+ ## [0.6.5] - 2026-04-12
2700
+
2701
+ ### Added
2702
+
2703
+ - Java JDBC and Kotlin JDBC: Oracle backend support
2704
+
2705
+ ### Fixed
2706
+
2707
+ - tokio-postgres: enums now implement `FromSql` and `ToSql` traits natively, enabling direct use as query parameters and row fields without manual string conversion
2708
+ - Ruby mysql2: `affected_rows` now called on the statement instead of the client, fixing incorrect return values for exec queries
2709
+
2710
+ ## [0.6.4] - 2026-04-10
2711
+
2712
+ ### Added
2713
+
2714
+ - Integration tests now run all generated code against real databases (PostgreSQL, MySQL, SQLite) across all 39 backends and 10 languages
2715
+ - CI split into 3 parallel jobs (PostgreSQL, MySQL, SQLite) covering all backends
2716
+ - New MySQL/SQLite SQL queries: GetUserOrders, CountUsersByStatus, GetUserWithTags
2717
+
2718
+ ### Fixed
2719
+
2720
+ - tokio-postgres: enum parameters now use `::text::enum_name` casts for proper PostgreSQL enum handling
2721
+ - tokio-postgres: enum columns in SELECT/RETURNING use `::text` cast for correct deserialization
2722
+ - sqlx: RETURNING clauses now include enum type annotations (`"status: UserStatus"`)
2723
+ - sqlx: aggregate functions (COUNT, SUM) get non-null override annotations (`"column_name!"`)
2724
+ - C# Npgsql: enum extension methods moved to top-level static classes (fixes CS1109)
2725
+ - C# Microsoft.Data.Sqlite: fixed type mappings (int32->long, float32->double for SQLite)
2726
+ - Elixir exqlite: updated to Exqlite 0.36 prepare/bind/step API
2727
+ - Elixir myxql/exqlite/ecto: generated code now properly wrapped in `defmodule`
2728
+ - Python aiomysql: `?` placeholders correctly rewritten to `%s`
2729
+ - Go pgx: added missing `time` and `decimal` imports in generated code
2730
+ - Ruby trilogy: parameterized queries use string interpolation (trilogy lacks prepared statement support)
2731
+ - TypeScript pg-zod: enum columns use correct Zod schema references
2732
+
2733
+ ## [0.6.3] - 2026-04-10
2734
+
2735
+ ### Added
2736
+
2737
+ - `fmt` and `lint` commands now auto-detect the SQL dialect from the config `engine` field (CLI `--dialect` flag still takes precedence)
2738
+
2739
+ ### Fixed
2740
+
2741
+ - Sqruff rule `LT01` excluded by default — it incorrectly splits compound operators (`>=`, `<=`, `<@`)
2742
+ - Compound operators inside CHECK constraints no longer get split by the formatter (e.g., `>=` becoming `> =`)
2743
+
2744
+ ## [0.6.2] - 2026-04-10
2745
+
2746
+ ### Changed
2747
+
2748
+ - tokio-postgres: `from_row` is now infallible (returns `Self` instead of `Result`) matching tokio-postgres `row.get()` conventions
2749
+ - tokio-postgres: all query functions uniformly return `Result<T, tokio_postgres::Error>` instead of mixed error types
2750
+ - tokio-postgres: extracted `ERROR_TYPE` constant to reduce string duplication in signatures
2751
+
2752
+ ### Fixed
2753
+
2754
+ - `:opt` command now correctly generates row structs (was missing from struct generation match)
2755
+
2756
+ ## [0.6.1] - 2026-04-10
2757
+
2758
+ ### Added
2759
+
2760
+ - `:opt` query command across all backends — returns optional/nullable single row (distinct from `:one` which expects exactly one row)
2761
+ - Serde and custom derive support for tokio-postgres backend via `serde` and `derive` options
2762
+ - `apply_options()` method on tokio-postgres backend for runtime configuration
2763
+ - `is_column_nullable()` helper on analyzer scope for nullable column lookups
2764
+ - `collect_param_from_expr_with_type_nullable()` for nullable-aware parameter collection
2765
+ - `version:sync` task in Taskfile for updating all crate versions at once
2766
+
2767
+ ### Changed
2768
+
2769
+ - tokio-postgres: `client` parameter now accepts `&(impl GenericClient + Sync)` instead of concrete `&Client`
2770
+ - tokio-postgres: batch functions no longer wrap operations in implicit transactions
2771
+
2772
+ ### Fixed
2773
+
2774
+ - INSERT parameter analysis now propagates column nullability to parameters
2775
+ - Changelog retroactively aligned with Cargo.toml version history (0.1.0–0.6.0)
2776
+
2777
+ ## [0.6.0] - 2026-04-08
2778
+
2779
+ ### Added
2780
+
2781
+ - Microsoft SQL Server engine (6 backends: tiberius, pyodbc, mssql, sqlclient, tiny_tds, tds)
2782
+ - Oracle Database engine (6 backends: sibyl, oracledb, godror, oracle, oci8, jamdb)
2783
+ - MariaDB engine with native UUID support, RETURNING clause, and dedicated manifests
2784
+ - Amazon Redshift engine (PostgreSQL-based with SUPER type support)
2785
+ - Snowflake engine with VARIANT/OBJECT/ARRAY types
2786
+ - 17 new database backends and 51 type mapping manifests
2787
+ - Pre-commit/prek hooks for scythe users
2788
+
2789
+ ### Changed
2790
+
2791
+ - Flattened docs structure for better organization
2792
+ - Expanded to 10 total databases with 70+ backend drivers across 10 languages
2793
+
2794
+ ### Fixed
2795
+
2796
+ - Extracted shared `rewrite_pg_placeholders` function (eliminated 26+ duplicated functions)
2797
+ - Extracted shared `load_or_default_manifest` function (eliminated 49 duplicated code blocks)
2798
+ - CockroachDB documentation TOML snippet duplicate key issue
2799
+ - Python DuckDB missing datetime import
2800
+ - TypeScript DuckDB import type issue
2801
+ - Go godror PascalCase conversion issue
2802
+ - Go unconditional imports problem
2803
+ - SQLx hardcoded PgPool issue
2804
+ - Tiberius unwrap error handling
2805
+ - Kotlin wasNull null handling
2806
+ - Ruby batch operation fix
2807
+ - Sibyl error swallowing issue
2808
+ - Go `interface{}` updated to `any` keyword
2809
+
2810
+ ## [0.5.0] - 2026-04-08
2811
+
2812
+ ### Added
2813
+
2814
+ - CockroachDB engine support
2815
+ - DuckDB engine support
2816
+ - `:grouped` operation support
2817
+ - Kotlin Exposed backend
2818
+ - R2DBC backend support
2819
+ - Homebrew bottles for distribution
2820
+ - Integration test generator for all 39 backend test suites
2821
+
2822
+ ## [0.4.0] - 2026-04-08
2823
+
2824
+ ### Added
2825
+
2826
+ - Real `:batch` operations across all backends
2827
+ - PHP AMPHP backend
2828
+ - Custom type overrides feature
2829
+ - `@optional` annotation support
2830
+ - Elixir Ecto backend
2831
+ - Ruby Trilogy backend
2832
+ - Pydantic/msgspec row types for Python
2833
+ - Zod v4 schemas for TypeScript
2834
+ - GenOptions infrastructure for per-backend configuration
2835
+
2836
+ ### Changed
2837
+
2838
+ - Extended Quick Start documentation with all 10 languages
2839
+
2840
+ ## [0.3.0] - 2026-04-07
2841
+
2842
+ ### Added
2843
+
2844
+ - Snippet-runner tool for validating documentation code snippets across 13 languages
2845
+ - PHP namespace support and Generator for `:many` queries
2846
+ - C# SQLite async API
2847
+ - Ruby module `Queries` encapsulation across all 3 backends
2848
+
2849
+ ### Changed
2850
+
2851
+ - C# all backends: Enum.TryParse with descriptive InvalidOperationException
2852
+ - Python aiosqlite: Decimal maps to `decimal.Decimal` instead of float
2853
+ - Go database-sql MySQL: Decimal maps to float64
2854
+ - Ruby: SCREAMING_SNAKE_CASE enum variants
2855
+ - PHP: Final class `Queries` wrapper
2856
+
2857
+ ### Fixed
2858
+
2859
+ - 8 backend-specific fixes across PHP, Ruby, C#, Rust, Python, and Go
2860
+
2861
+ ## [0.2.0] - 2026-04-07
2862
+
2863
+ ### Added
2864
+
2865
+ - Engine-aware backend architecture — `get_backend(name, engine)` loads engine-specific manifests
2866
+ - 12 new language backends for MySQL and SQLite: go-database-sql, python-aiomysql, python-aiosqlite, typescript-mysql2, typescript-better-sqlite3, ruby-mysql2, ruby-sqlite3, csharp-mysqlconnector, csharp-microsoft-sqlite, elixir-myxql, elixir-exqlite
2867
+ - Multi-backend CLI config via `[[sql.gen]]` array syntax in scythe.toml
2868
+ - Full MySQL support across all 10 languages (Rust, Go, Python, TypeScript, Java, Kotlin, C#, Elixir, Ruby, PHP)
2869
+ - Full SQLite support across all 10 languages
2870
+ - 33 real integration tests against PostgreSQL, MySQL, and SQLite
2871
+ - `supported_engines()` method on CodegenBackend trait for engine validation
2872
+ - `manifest()` method on CodegenBackend trait for direct manifest access
2873
+ - `file_footer()` method on CodegenBackend trait for class wrappers (C#)
2874
+ - Engine-specific manifest files for multi-DB backends (java-jdbc, kotlin-jdbc, php-pdo, rust-sqlx)
2875
+ - Docker Compose setup for integration testing (PostgreSQL + MySQL)
2876
+
2877
+ ### Changed
2878
+
2879
+ - `get_backend()` now requires engine parameter for database-aware code generation
2880
+ - Backend constructors accept engine parameter and load appropriate manifests
2881
+ - PG-only backends reject non-PostgreSQL engines with clear error messages
2882
+
2883
+ ### Fixed
2884
+
2885
+ - Python codegen: multiline SQL now uses triple-quoted strings
2886
+ - Python codegen: added missing `import decimal` to file headers
2887
+ - TypeScript pg codegen: multiline SQL now uses backtick template literals
2888
+ - C# codegen: generated code now wrapped in `public static class Queries { }`
2889
+ - C# codegen: enum parameters use `.ToString().ToLower()` with `::enum_type` SQL cast
2890
+ - C# codegen: enum columns deserialized via `Enum.Parse<T>(reader.GetString(i), true)`
2891
+ - PHP codegen: MySQL `?` placeholders use positional arrays instead of named params
2892
+ - PHP codegen: enum params use `->value`, enum columns use `::from()`, DateTimeImmutable for timestamps
2893
+ - Go codegen: added missing `time` and `decimal` imports to file header
2894
+ - Java codegen: added import statements to file header
2895
+ - Ruby mysql2 codegen: `affected_rows` called on statement instead of client
2896
+
2897
+ ## [0.1.0] - 2026-04-06
2898
+
2899
+ ### Added
2900
+
2901
+ - SQL-to-code generation for 13 language backends:
2902
+ - Rust (sqlx, tokio-postgres)
2903
+ - Python (psycopg3, asyncpg)
2904
+ - TypeScript (postgres.js, pg)
2905
+ - Go (pgx v5)
2906
+ - Java (JDBC with records)
2907
+ - Kotlin (JDBC with data classes)
2908
+ - C# (Npgsql with records)
2909
+ - Elixir (Postgrex with defstruct)
2910
+ - Ruby (pg gem with Data.define)
2911
+ - PHP (PDO with readonly classes)
2912
+ - Database dialect support: PostgreSQL, MySQL, SQLite
2913
+ - SQL annotation system (@name, @returns, @param, @nullable, @nonnull, @json, @deprecated)
2914
+ - Smart type inference with nullability propagation (JOIN, COALESCE, aggregates, CASE)
2915
+ - Language-neutral type vocabulary with per-backend type mapping via manifest.toml
2916
+ - 93 SQL lint rules (22 scythe-specific + 71 via sqruff integration)
2917
+ - SQL formatting via sqruff integration
2918
+ - CLI commands: generate, check, lint, fmt, migrate
2919
+ - sqlc migration tool (convert sqlc.yaml to scythe.toml, migrate query annotations)
2920
+ - 275 JSON test fixtures with auto-generated test code
2921
+ - Real language tool validation (ruff, biome, gofmt, ktlint, ruby -c, php -l)
2922
+ - Template-based backend architecture (manifest.toml + MiniJinja templates)
2923
+ - Trait-based CodegenBackend for extensible language support