Add tests, schema sync safeguards, and query/handler improvements

- Add bun test suite: SQL generator and value unit tests, plus MariaDB
  integration tests gated on BUN_MARIADB_TEST_DB
- schema: add --dry-run and require confirmation (or --yes) before
  dropping tables/columns; block unapproved destructive statements
- Always AND targetId with the query, regardless of searchOperator
- Initialize lazily on first call; init throws instead of exiting
- Generate IN (?, ?, ...) lists for IN / NOT IN
- Share value binding between insert and update (booleans, embeddings,
  function values, "" -> NULL for non-text columns)
- Keep Buffers and convert BigInt/Date without a JSON round-trip
- DbSQL: report success for empty SELECT results
- Run update() in a transaction with row locking
- Key the client cache on the full connection config
- Consolidate identifier quoting, drop dead code, merge column lookup
- Read CLI version from package.json, pin @types/bun, chmod CLI on compile
- Rebuild dist

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 02:27:59 +01:00
co-authored by Claude Opus 5.5
parent b81b09324a
commit ddf431e866
82 changed files with 2140 additions and 1403 deletions
+18 -23
View File
@@ -1,3 +1,4 @@
import { columnRef, sqlLogicalOperator, sqlRawComparison, } from "./sql-identifier";
export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
let values = [];
if (mtch.__batch) {
@@ -13,7 +14,7 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
btch_mtch += str;
values.push(...batch_values);
if (i < mtch.__batch.matches.length - 1) {
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
btch_mtch += ` ${sqlLogicalOperator(mtch.__batch.operator || "OR")} `;
}
}
btch_mtch += `)`;
@@ -22,28 +23,12 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
values,
};
}
const equality = mtch.raw_equality || "=";
const lhs = `${typeof mtch.source == "object" ? mtch.source.tableName : table_name}.${typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source}`;
const rhs = `${(() => {
if (mtch.targetLiteral) {
values.push(mtch.targetLiteral);
// if (typeof mtch.targetLiteral == "number") {
// return `${mtch.targetLiteral}`;
// }
// return `'${mtch.targetLiteral}'`;
return `?`;
}
if (join.alias) {
return `${typeof mtch.target == "object"
? mtch.target.tableName
: join.alias}.${typeof mtch.target == "object"
? mtch.target.fieldName
: mtch.target}`;
}
return `${typeof mtch.target == "object"
? mtch.target.tableName
: join.tableName}.${typeof mtch.target == "object" ? mtch.target.fieldName : mtch.target}`;
})()}`;
const equality = mtch.raw_equality
? sqlRawComparison(mtch.raw_equality)
: "=";
const lhs = typeof mtch.source == "object"
? columnRef(mtch.source.fieldName, mtch.source.tableName)
: columnRef(String(mtch.source), table_name);
if (mtch.between) {
values.push(mtch.between.min, mtch.between.max);
return {
@@ -58,6 +43,16 @@ export default function sqlGenGenJoinStr({ join, mtch, table_name }) {
values,
};
}
const rhs = (() => {
if (mtch.targetLiteral !== undefined && mtch.targetLiteral !== null) {
values.push(mtch.targetLiteral);
return `?`;
}
if (typeof mtch.target == "object") {
return columnRef(mtch.target.fieldName, mtch.target.tableName);
}
return columnRef(String(mtch.target), join.alias || join.tableName);
})();
return {
str: `${lhs} ${equality} ${rhs}`,
values,