Updates
This commit is contained in:
+3
@@ -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 = [];
|
||||
|
||||
Vendored
+1
-1
@@ -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.
|
||||
|
||||
Vendored
+10
-4
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user