Files
Jyotisha/frontend/tests/local-postgres-not.test.ts
T
jesse-ux df329fa96c
Independent Staging Quality Gate / validate (push) Successful in 10m31s
Independent Staging Quality Gate / publish (push) Successful in 3m37s
fix(web): support PostgREST not(col, is) so archived session lists load
Local Postgres not() only handled eq/cs, so archived=1 threw and the sidebar archive view returned 500. Compile is not null/true/false instead of inequality.
2026-09-21 17:45:07 +08:00

34 lines
1.3 KiB
TypeScript

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();
}
});