This commit is contained in:
2026-09-08 07:24:00 +01:00
parent d4097a5e5d
commit 2ddf450b9f
7 changed files with 32 additions and 10 deletions
+3
View File
@@ -28,6 +28,9 @@ export default function generateTypeDefinition({ paradigm, table, query, typeDef
if (schemaType.dataType?.match(/boolean/i)) {
return "0 | 1";
}
if (schemaType.dataType?.match(/vector/i) || schemaType.isVector) {
return `string | number[] | Buffer<ArrayBufferLike> | Float32Array<ArrayBuffer>`;
}
return "string";
}
const typesArrayTypeScript = [];
+1 -1
View File
@@ -1302,7 +1302,7 @@ export interface SQLInsertGenReturn {
/**
* Values accepted by the SQL insert generator, including vector buffers.
*/
export type SQLInsertGenValueType = string | number | Float32Array<ArrayBuffer> | Buffer<ArrayBuffer> | null;
export type SQLInsertGenValueType = string | number | Float32Array<ArrayBuffer> | Buffer<ArrayBuffer> | number[] | null;
/**
* Callback variant used when a generated insert value needs a custom
* placeholder.
+10 -4
View File
@@ -23,14 +23,18 @@ export default function sqlInsertGenerator({ tableName, data, dbFullName, }) {
queryBatches.push(`(${insertKeys
.map((ky) => {
const value = item[ky];
const is_embedding = Array.isArray(value) &&
typeof value[0] == "number";
const finalValue = typeof value == "string" ||
typeof value == "number"
? value
: typeof value == "function"
? value().value
: value
? value
: null;
: is_embedding
? JSON.stringify(value)
: value
? value
: null;
if (!finalValue && typeof value !== "number") {
queryValues.push(null);
return "?";
@@ -38,7 +42,9 @@ export default function sqlInsertGenerator({ tableName, data, dbFullName, }) {
queryValues.push(finalValue);
const placeholder = typeof value == "function"
? value().placeholder
: "?";
: is_embedding
? "VEC_FromText(?)"
: "?";
return placeholder;
})
.filter((k) => Boolean(k))