mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
bump webkit (#22256)
### What does this PR do? ### How did you verify your code works? --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -330,7 +330,7 @@ describe("Connection & Initialization", () => {
|
||||
const result = await sql`SELECT * FROM test`;
|
||||
expect(result).toHaveLength(1);
|
||||
|
||||
expect(sql`INSERT INTO test VALUES (2)`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
expect(async () => await sql`INSERT INTO test VALUES (2)`.execute()).toThrowErrorMatchingInlineSnapshot(
|
||||
`"attempt to write a readonly database"`,
|
||||
);
|
||||
|
||||
@@ -691,7 +691,9 @@ describe("Connection & Initialization", () => {
|
||||
expect(sql.options.readonly).toBe(true);
|
||||
expect(sql.options.filename).toBe(dbPath);
|
||||
|
||||
expect(sql`SELECT 1`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(`"unable to open database file"`);
|
||||
expect(async () => await sql`SELECT 1`.execute()).toThrowErrorMatchingInlineSnapshot(
|
||||
`"unable to open database file"`,
|
||||
);
|
||||
|
||||
await sql.close();
|
||||
await rm(dir, { recursive: true });
|
||||
@@ -964,7 +966,7 @@ describe("Template Literal Security", () => {
|
||||
test("dynamic table names are not allowed in template literals", async () => {
|
||||
const tableName = "users";
|
||||
|
||||
expect(sql`CREATE TABLE ${tableName} (id INTEGER)`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
expect(async () => await sql`CREATE TABLE ${tableName} (id INTEGER)`.execute()).toThrowErrorMatchingInlineSnapshot(
|
||||
`"near "?": syntax error"`,
|
||||
);
|
||||
|
||||
@@ -989,9 +991,9 @@ describe("Template Literal Security", () => {
|
||||
test("dynamic SQL structure is not allowed in template literals", async () => {
|
||||
const columns = "id INTEGER, name TEXT";
|
||||
|
||||
expect(sql`CREATE TABLE dynamic_structure (${columns})`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"near "?": syntax error"`,
|
||||
);
|
||||
expect(
|
||||
async () => await sql`CREATE TABLE dynamic_structure (${columns})`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"near "?": syntax error"`);
|
||||
|
||||
await sql.unsafe(`CREATE TABLE dynamic_structure (${columns})`);
|
||||
const tables = await sql`SELECT name FROM sqlite_master WHERE type='table' AND name='dynamic_structure'`;
|
||||
@@ -1024,7 +1026,7 @@ describe("Template Literal Security", () => {
|
||||
expect(result[0].name).toBe("Alice");
|
||||
|
||||
const table = "identifier_test";
|
||||
expect(sql`SELECT * FROM ${table}`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
expect(async () => await sql`SELECT * FROM ${table}`.execute()).toThrowErrorMatchingInlineSnapshot(
|
||||
`"near "?": syntax error"`,
|
||||
);
|
||||
});
|
||||
@@ -1032,8 +1034,8 @@ describe("Template Literal Security", () => {
|
||||
test("sql([...]) helper not allowed when 'where in' appears only in string literal", async () => {
|
||||
const sql = new SQL("sqlite://:memory:");
|
||||
expect(
|
||||
sql`SELECT 'this has where in inside a string' ${sql([1, 2])}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(`"Helpers are only allowed for INSERT, UPDATE and WHERE IN commands"`);
|
||||
async () => await sql`SELECT 'this has where in inside a string' ${sql([1, 2])}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Helpers are only allowed for INSERT, UPDATE and WHERE IN commands"`);
|
||||
await sql.close();
|
||||
});
|
||||
});
|
||||
@@ -1089,7 +1091,7 @@ describe("Transactions", () => {
|
||||
try {
|
||||
await tx.savepoint(async sp => {
|
||||
await sp`UPDATE accounts SET balance = balance - 200 WHERE id = 1`;
|
||||
throw new Error("Inner transaction failed");
|
||||
throw new Error("Inner! transaction failed");
|
||||
});
|
||||
} catch (err) {}
|
||||
|
||||
@@ -1105,10 +1107,11 @@ describe("Transactions", () => {
|
||||
// It only supports DEFERRED (default), IMMEDIATE, and EXCLUSIVE
|
||||
test("read-only transactions throw appropriate error", async () => {
|
||||
expect(
|
||||
sql.begin("readonly", async tx => {
|
||||
return await tx`SELECT * FROM accounts`;
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
async () =>
|
||||
await sql.begin("readonly", async tx => {
|
||||
return await tx`SELECT * FROM accounts`;
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"SQLite doesn't support 'readonly' transaction mode. Use DEFERRED, IMMEDIATE, or EXCLUSIVE."`,
|
||||
);
|
||||
});
|
||||
@@ -1341,88 +1344,71 @@ describe("Helper argument validation", () => {
|
||||
test("functions are invalid values in helper", async () => {
|
||||
const fn = () => 123;
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 1, text_val: fn })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () => await sql`INSERT INTO helper_invalid ${sql({ id: 1, text_val: fn })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
});
|
||||
|
||||
test("plain objects (JSON) are invalid values in helper", async () => {
|
||||
const obj = { a: 1, b: "two" };
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 2, text_val: obj as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () => await sql`INSERT INTO helper_invalid ${sql({ id: 2, text_val: obj as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
});
|
||||
|
||||
test("Map and Set are invalid values in helper", async () => {
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 3, text_val: new Map([["k", "v"]]) as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 3, text_val: new Map([["k", "v"]]) as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 4, text_val: new Set([1, 2, 3]) as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 4, text_val: new Set([1, 2, 3]) as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
});
|
||||
|
||||
test("Response, Request, Blob, File are invalid values in helper", async () => {
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 5, text_val: new Response("ok") as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 5, text_val: new Response("ok") as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 6, text_val: new Request("https://example.com") as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 6, text_val: new Request("https://example.com") as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 7, blob_val: new Blob(["hello"]) as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 7, blob_val: new Blob(["hello"]) as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 8, blob_val: new File(["body"], "a.txt") as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 8, blob_val: new File(["body"], "a.txt") as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
});
|
||||
|
||||
test("ArrayBuffer (not a view) is invalid in helper", async () => {
|
||||
const ab = new ArrayBuffer(8);
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 9, blob_val: ab as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () => await sql`INSERT INTO helper_invalid ${sql({ id: 9, blob_val: ab as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
});
|
||||
|
||||
test("Promise, Date, RegExp are invalid in helper", async () => {
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 10, text_val: Promise.resolve("x") as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () =>
|
||||
await sql`INSERT INTO helper_invalid ${sql({ id: 10, text_val: Promise.resolve("x") as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 11, text_val: new Date() as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () => await sql`INSERT INTO helper_invalid ${sql({ id: 11, text_val: new Date() as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
|
||||
expect(
|
||||
sql`INSERT INTO helper_invalid ${sql({ id: 12, text_val: /abc/ as any })}`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
async () => await sql`INSERT INTO helper_invalid ${sql({ id: 12, text_val: /abc/ as any })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Binding expected string, TypedArray, boolean, number, bigint or null"`);
|
||||
});
|
||||
|
||||
test("BigInt values are accepted when in range", async () => {
|
||||
@@ -1437,9 +1423,9 @@ describe("Helper argument validation", () => {
|
||||
await sqlSafe`CREATE TABLE t (id INTEGER PRIMARY KEY, n INTEGER)`;
|
||||
|
||||
const big = BigInt("9223372036854775808"); // 2^63, just out of int64 range
|
||||
expect(sqlSafe`INSERT INTO t ${sql({ id: 1, n: big })}`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"BigInt value '9223372036854775808' is out of range"`,
|
||||
);
|
||||
expect(
|
||||
async () => await sqlSafe`INSERT INTO t ${sql({ id: 1, n: big })}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"BigInt value '9223372036854775808' is out of range"`);
|
||||
await sqlSafe.close();
|
||||
});
|
||||
|
||||
@@ -1476,20 +1462,20 @@ describe("Helper argument validation", () => {
|
||||
|
||||
test("WHERE IN helper rejects multiple columns", async () => {
|
||||
const items = [{ a: 1, b: 2 }];
|
||||
expect(sql`SELECT 1 WHERE 1 IN ${sql(items, "a", "b")}`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Cannot use WHERE IN helper with multiple columns"`,
|
||||
);
|
||||
expect(
|
||||
async () => await sql`SELECT 1 WHERE 1 IN ${sql(items, "a", "b")}`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Cannot use WHERE IN helper with multiple columns"`);
|
||||
});
|
||||
|
||||
test("UPDATE helper rejects array of objects", async () => {
|
||||
const items = [{ text_val: "a" }, { text_val: "b" }];
|
||||
expect(
|
||||
sql`UPDATE helper_invalid SET ${sql(items)} WHERE id = 1`.execute(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(`"Cannot use array of objects for UPDATE"`);
|
||||
async () => await sql`UPDATE helper_invalid SET ${sql(items)} WHERE id = 1`.execute(),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"Cannot use array of objects for UPDATE"`);
|
||||
});
|
||||
|
||||
test("invalid values in WHERE IN helper are rejected", async () => {
|
||||
expect(sql`SELECT 1 WHERE 1 IN ${sql([() => {}])}`.execute()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
expect(async () => await sql`SELECT 1 WHERE 1 IN ${sql([() => {}])}`.execute()).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Binding expected string, TypedArray, boolean, number, bigint or null"`,
|
||||
);
|
||||
});
|
||||
@@ -1582,7 +1568,7 @@ describe("Connection management", () => {
|
||||
test("reserve throws for SQLite", async () => {
|
||||
const sql = new SQL("sqlite://:memory:");
|
||||
|
||||
expect(sql.reserve()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
expect(async () => await sql.reserve()).toThrowErrorMatchingInlineSnapshot(
|
||||
`"This adapter doesn't support connection reservation"`,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user