Transform JSON / JSONB parameter keys
Hey @porsager, hope you're good! 👋
Postgres.js transforms JS property names passed through `sql(...)` helpers, eg. with `{ transform: postgres.camel }`:
```js
sql({ firstName: 'Ada' }) // { first_name: 'Ada' }
```
However, currently JSON parameter keys are not transformed 💥
```js
sql.json({ firstName: 'Ada' }) // {"firstName":"Ada"}
```
Maybe this was an oversight in my previous PR for "nested transforms":
- #460
This PR adds JSON value transforms before serialization for the built-in case transforms, so JSON and JSONB parameters serialize transformed keys:
```js
sql.json({ firstName: 'Ada' }) // {"first_name":"Ada"}
```
This change also applies to JSON / JSONB data created via `sql.typed()` and type casts:
```js
sql.typed({ firstName: 'Ada' }, 114) // {"first_name":"Ada"}
sql`${ { firstName: 'Ada' } }::jsonb` // {"first_name":"Ada"}
```
- [x] Transform JSON / JSONB parameter keys
- [x] Add `value.to` transforms for camel, pascal, and kebab
- [x] Test nested objects, arrays, result parsing, and untransformed JSON
- [x] Test implicit and typed JSON parameters
- [x] Update types
AI disclosure: guided use of `gpt-5.5 high` through Codex CLI
合并状态:未合并 6 条评论