1import { PgliteClient } from "@effect/sql-pglite"
2import { assert, describe, layer } from "@effect/vitest"
3import { Effect } from "effect"
4
5describe("PgliteClient JSON values", () => {
6 layer(PgliteClient.layer(), { timeout: "30 seconds" })((it) => {
7 for (const type of ["json", "jsonb"]) {
8 it.effect.each(["null", "123", "hello", "", "\"quoted\"\\\n"])(
9 `${type} preserves the string %j`,
10 (input) =>
11 Effect.gen(function*() {
12 const sql = yield* PgliteClient.PgliteClient
13 const rows = yield* sql<{ value: unknown }>`SELECT ${sql.json(input)}::${sql.literal(type)} AS value`
14 assert.deepStrictEqual(rows, [{ value: input }])
15 })
16 )
17 }
18 })
19})