t3-code-android-nightly/.repos/effect-smol/packages/sql/pglite/test/Json.test.ts
Julius Marminge e3c85ead63
chore(refs): sync Effect and Alchemy references to rc.115 and beta.78 (#12327)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-17 23:21:25 -07:00

19 lines
730 B
TypeScript

import { PgliteClient } from "@effect/sql-pglite"
import { assert, describe, layer } from "@effect/vitest"
import { Effect } from "effect"
describe("PgliteClient JSON values", () => {
layer(PgliteClient.layer(), { timeout: "30 seconds" })((it) => {
for (const type of ["json", "jsonb"]) {
it.effect.each(["null", "123", "hello", "", "\"quoted\"\\\n"])(
`${type} preserves the string %j`,
(input) =>
Effect.gen(function*() {
const sql = yield* PgliteClient.PgliteClient
const rows = yield* sql<{ value: unknown }>`SELECT ${sql.json(input)}::${sql.literal(type)} AS value`
assert.deepStrictEqual(rows, [{ value: input }])
})
)
}
})
})