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)) {
|
if (schemaType.dataType?.match(/boolean/i)) {
|
||||||
return "0 | 1";
|
return "0 | 1";
|
||||||
}
|
}
|
||||||
|
if (schemaType.dataType?.match(/vector/i) || schemaType.isVector) {
|
||||||
|
return `string | number[] | Buffer<ArrayBufferLike> | Float32Array<ArrayBuffer>`;
|
||||||
|
}
|
||||||
return "string";
|
return "string";
|
||||||
}
|
}
|
||||||
const typesArrayTypeScript = [];
|
const typesArrayTypeScript = [];
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1302,7 +1302,7 @@ export interface SQLInsertGenReturn {
|
|||||||
/**
|
/**
|
||||||
* Values accepted by the SQL insert generator, including vector buffers.
|
* 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
|
* Callback variant used when a generated insert value needs a custom
|
||||||
* placeholder.
|
* placeholder.
|
||||||
|
|||||||
Vendored
+6
@@ -23,11 +23,15 @@ export default function sqlInsertGenerator({ tableName, data, dbFullName, }) {
|
|||||||
queryBatches.push(`(${insertKeys
|
queryBatches.push(`(${insertKeys
|
||||||
.map((ky) => {
|
.map((ky) => {
|
||||||
const value = item[ky];
|
const value = item[ky];
|
||||||
|
const is_embedding = Array.isArray(value) &&
|
||||||
|
typeof value[0] == "number";
|
||||||
const finalValue = typeof value == "string" ||
|
const finalValue = typeof value == "string" ||
|
||||||
typeof value == "number"
|
typeof value == "number"
|
||||||
? value
|
? value
|
||||||
: typeof value == "function"
|
: typeof value == "function"
|
||||||
? value().value
|
? value().value
|
||||||
|
: is_embedding
|
||||||
|
? JSON.stringify(value)
|
||||||
: value
|
: value
|
||||||
? value
|
? value
|
||||||
: null;
|
: null;
|
||||||
@@ -38,6 +42,8 @@ export default function sqlInsertGenerator({ tableName, data, dbFullName, }) {
|
|||||||
queryValues.push(finalValue);
|
queryValues.push(finalValue);
|
||||||
const placeholder = typeof value == "function"
|
const placeholder = typeof value == "function"
|
||||||
? value().placeholder
|
? value().placeholder
|
||||||
|
: is_embedding
|
||||||
|
? "VEC_FromText(?)"
|
||||||
: "?";
|
: "?";
|
||||||
return placeholder;
|
return placeholder;
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/bun-mariadb",
|
"name": "@moduletrace/bun-mariadb",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"description": "Schema-driven MariaDB manager for Bun",
|
"description": "Schema-driven MariaDB manager for Bun",
|
||||||
"author": "Benjamin Toby",
|
"author": "Benjamin Toby",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ export default function generateTypeDefinition({
|
|||||||
return "0 | 1";
|
return "0 | 1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schemaType.dataType?.match(/vector/i) || schemaType.isVector) {
|
||||||
|
return `string | number[] | Buffer<ArrayBufferLike> | Float32Array<ArrayBuffer>`;
|
||||||
|
}
|
||||||
|
|
||||||
return "string";
|
return "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1479,6 +1479,7 @@ export type SQLInsertGenValueType =
|
|||||||
| number
|
| number
|
||||||
| Float32Array<ArrayBuffer>
|
| Float32Array<ArrayBuffer>
|
||||||
| Buffer<ArrayBuffer>
|
| Buffer<ArrayBuffer>
|
||||||
|
| number[]
|
||||||
| null;
|
| null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,12 +40,18 @@ export default function sqlInsertGenerator({
|
|||||||
.map((ky) => {
|
.map((ky) => {
|
||||||
const value = item[ky];
|
const value = item[ky];
|
||||||
|
|
||||||
|
const is_embedding =
|
||||||
|
Array.isArray(value) &&
|
||||||
|
typeof value[0] == "number";
|
||||||
|
|
||||||
const finalValue =
|
const finalValue =
|
||||||
typeof value == "string" ||
|
typeof value == "string" ||
|
||||||
typeof value == "number"
|
typeof value == "number"
|
||||||
? value
|
? value
|
||||||
: typeof value == "function"
|
: typeof value == "function"
|
||||||
? value().value
|
? value().value
|
||||||
|
: is_embedding
|
||||||
|
? JSON.stringify(value)
|
||||||
: value
|
: value
|
||||||
? value
|
? value
|
||||||
: null;
|
: null;
|
||||||
@@ -60,6 +66,8 @@ export default function sqlInsertGenerator({
|
|||||||
const placeholder =
|
const placeholder =
|
||||||
typeof value == "function"
|
typeof value == "function"
|
||||||
? value().placeholder
|
? value().placeholder
|
||||||
|
: is_embedding
|
||||||
|
? "VEC_FromText(?)"
|
||||||
: "?";
|
: "?";
|
||||||
|
|
||||||
return placeholder;
|
return placeholder;
|
||||||
|
|||||||
Reference in New Issue
Block a user