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
+16 -7
View File
@@ -10,9 +10,12 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
if (queryObj.notNullValue) {
return { str: `${fieldName} IS NOT NULL` };
}
if (value) {
// `0` is a real value; only null / undefined / "" count as "no value"
const hasValue = value !== undefined && value !== null && value !== "";
if (hasValue) {
const finalValue = isValueFieldValue ? value : "?";
const finalParams = isValueFieldValue ? undefined : value;
const likeParams = isValueFieldValue ? undefined : `%${value}%`;
if (equality == "MATCH") {
return {
str: `MATCH(${fieldName}) AGAINST(${finalValue} IN NATURAL LANGUAGE MODE)`,
@@ -28,7 +31,7 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
else if (equality == "LIKE_LOWER") {
return {
str: `LOWER(${fieldName}) LIKE LOWER(${finalValue})`,
param: `%${finalParams}%`,
param: likeParams,
};
}
else if (equality == "LIKE_LOWER_RAW") {
@@ -40,7 +43,7 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
else if (equality == "LIKE") {
return {
str: `${fieldName} LIKE ${finalValue}`,
param: `%${finalParams}%`,
param: likeParams,
};
}
else if (equality == "LIKE_RAW") {
@@ -52,7 +55,7 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
else if (equality == "NOT_LIKE_LOWER") {
return {
str: `LOWER(${fieldName}) NOT LIKE LOWER(${finalValue})`,
param: `%${finalParams}%`,
param: likeParams,
};
}
else if (equality == "NOT_LIKE_LOWER_RAW") {
@@ -64,7 +67,7 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
else if (equality == "NOT LIKE") {
return {
str: `${fieldName} NOT LIKE ${finalValue}`,
param: finalParams,
param: likeParams,
};
}
else if (equality == "NOT LIKE_RAW") {
@@ -97,6 +100,12 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
param: finalParams,
};
}
else if (equality == "IN" || equality == "NOT IN") {
return {
str: `${fieldName} ${equality} (${finalValue})`,
param: finalParams,
};
}
else if (equality) {
return {
str: `${fieldName} ${sqlEqualityParser(equality)} ${finalValue}`,
@@ -120,13 +129,13 @@ export default function sqlGenOperatorGen({ fieldName, value, equality, queryObj
else if (equality) {
return {
str: `${fieldName} ${sqlEqualityParser(equality)} ?`,
param: value,
param: value ?? "",
};
}
else {
return {
str: `${fieldName} = ?`,
param: value,
param: value ?? "",
};
}
}