Files
WRNexusJS/packages/db/test/bunsql-placeholders.test.ts
2026-07-30 13:36:29 +05:30

18 lines
661 B
TypeScript

import { expect, test } from "bun:test";
import { sqlForDialect } from "../src/adapters/bunsql.ts";
test("PostgreSQL converts portable placeholders to numbered parameters", () => {
expect(sqlForDialect("SELECT * FROM users WHERE id = ? AND status = ?", "postgres")).toBe(
"SELECT * FROM users WHERE id = $1 AND status = $2",
);
});
test("MySQL and parameter-free PostgreSQL statements remain unchanged", () => {
expect(sqlForDialect("SELECT * FROM users WHERE id = ?", "mysql")).toBe(
"SELECT * FROM users WHERE id = ?",
);
expect(sqlForDialect("CREATE TABLE users (id TEXT)", "postgres")).toBe(
"CREATE TABLE users (id TEXT)",
);
});