Commit d85baf6
fix(codegen-ts): SQLite isArray columns emit .\$type<E[]>() for typed JSON
When isArray:true on SQLite, the column maps to text("col",{mode:"json"})
which Drizzle infers as `unknown` without an explicit .\$type<>()
annotation. The downstream InferSelectModel then leaves the field
`unknown`, forcing consumers to cast back to the actual element type.
Add the chain `.\$type<E[]>()` where E is the TS element type for the
field's scalar subType (string for STRING/ENUM/CLASS/DATE/TIME/TIMESTAMP/
DECIMAL, number for INT/LONG/CURRENCY/DOUBLE/FLOAT, boolean for BOOLEAN).
Object refs leave .\$type unset — consumers layer their own richer
schema there. Postgres .array() path is untouched (already element-typed).
Surfaced by wizardsofodd.com: with this fix, src/db/generated/Wizard.ts's
`bickersWith` becomes `string[]` instead of `unknown`, matching the
payload-side Wizard interface and removing the last source of `as
unknown as` casts in the consumer.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bd78989 commit d85baf6
2 files changed
Lines changed: 60 additions & 1 deletion
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
66 | 96 | | |
67 | 97 | | |
68 | 98 | | |
| |||
226 | 256 | | |
227 | 257 | | |
228 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
229 | 271 | | |
230 | 272 | | |
231 | 273 | | |
| |||
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
60 | 77 | | |
61 | 78 | | |
62 | 79 | | |
| |||
0 commit comments