Elffuss BraidHub

kikocis/lancedb public

main · 917 BRawPermalink
1import { IntoSql, toSQL } from "../lancedb/util";
2test.each([
3 ["string", "'string'"],
4 [123, "123"],
5 [1.11, "1.11"],
6 [true, "TRUE"],
7 [false, "FALSE"],
8 [null, "NULL"],
9 [new Date("2021-01-01T00:00:00.000Z"), "'2021-01-01T00:00:00.000Z'"],
10 [[1, 2, 3], "[1, 2, 3]"],
11 [new ArrayBuffer(8), "X'0000000000000000'"],
12 [Buffer.from("hello"), "X'68656c6c6f'"],
13 ["Hello 'world'", "'Hello ''world'''"],
14])("toSQL(%p) === %p", (value, expected) => {
15 expect(toSQL(value)).toBe(expected);
16});
17
18test("toSQL({}) throws on unsupported value type", () => {
19 expect(() => toSQL({} as unknown as IntoSql)).toThrow(
20 "Unsupported value type: object value: ([object Object])",
21 );
22});
23test("toSQL() throws on unsupported value type", () => {
24 // biome-ignore lint/suspicious/noExplicitAny: <explanation>
25 expect(() => (<any>toSQL)()).toThrow(
26 "Unsupported value type: undefined value: (undefined)",
27 );
28});