import assert from "node:assert/strict"; import test from "node:test"; import { closeLocalPostgresDataPools, compileUnaryIsClause, createLocalPostgresDataClient, } from "../src/lib/db/local-postgres-client-core.ts"; test("not(col, is, null) compiles to IS NOT NULL rather than inequality", () => { const sql = compileUnaryIsClause("archived_at", null, true); assert.equal(sql, '"archived_at" is not null'); assert.doesNotMatch(sql, /<>/); assert.equal(compileUnaryIsClause("archived_at", true, true), '"archived_at" is not true'); assert.equal(compileUnaryIsClause("archived_at", false, true), '"archived_at" is not false'); assert.equal(compileUnaryIsClause("archived_at", null, false), '"archived_at" is null'); }); test("not(col, is, undefined) still throws", async () => { assert.throws(() => compileUnaryIsClause("archived_at", undefined, true), /unsupported not filter/); const local = createLocalPostgresDataClient( "postgresql://unused:unused@127.0.0.1:9/unused", { id: "11111111-1111-4111-8111-111111111111", email: "unused@example.com" }, ); try { assert.throws( () => local.from("chat_sessions").select("id").not("archived_at", "is", undefined), /unsupported not filter/, ); } finally { await closeLocalPostgresDataPools(); } });