Add queue tables, quote SQL identifiers (v1.3.0)
- isQueue table option adds queue columns and a (status, available_at) index; BunSQLite.queue exposes add, claim, complete, fail and release_stale with atomic claims - Set busy_timeout on connections so workers in separate processes wait instead of failing with SQLITE_BUSY - Quote table and column names with backticks in generated SQL, so reserved words (to, order, group) work and unknown columns error instead of matching as string literals - Tests for queue ops, multi-process claims and reserved-word names Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -3,7 +3,7 @@ import type {
|
||||
ServerQueryParamsJoinMatchObject,
|
||||
SQLInsertGenValueType,
|
||||
} from "../types";
|
||||
import { sqlIdent, sqlOperator, sqlRawEquality } from "./sql-safe";
|
||||
import { sqlName, sqlOperator, sqlRawEquality } from "./sql-safe";
|
||||
|
||||
type Param = {
|
||||
mtch: ServerQueryParamsJoinMatchObject;
|
||||
@@ -48,10 +48,12 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }: Param) {
|
||||
|
||||
const equality = mtch.raw_equality ? sqlRawEquality(mtch.raw_equality) : "=";
|
||||
|
||||
const lhs = `${sqlIdent(
|
||||
typeof mtch.source == "object" ? mtch.source.tableName : table_name,
|
||||
"table name",
|
||||
)}.${sqlIdent(
|
||||
// `table_name` is already validated and quoted by `sqlGenerator`
|
||||
const lhs = `${
|
||||
typeof mtch.source == "object"
|
||||
? sqlName(mtch.source.tableName, "table name")
|
||||
: table_name
|
||||
}.${sqlName(
|
||||
typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source,
|
||||
"field name",
|
||||
)}`;
|
||||
@@ -90,7 +92,7 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }: Param) {
|
||||
? mtch.target.fieldName
|
||||
: mtch.target;
|
||||
|
||||
return `${sqlIdent(targetTable, "table name")}.${sqlIdent(
|
||||
return `${sqlName(targetTable, "table name")}.${sqlName(
|
||||
targetField,
|
||||
"field name",
|
||||
)}`;
|
||||
|
||||
Reference in New Issue
Block a user