Bugfix
This commit is contained in:
parent
959465a006
commit
b73309e9d5
15
dist/lib/sqlite/db-generate-type-defs.js
vendored
15
dist/lib/sqlite/db-generate-type-defs.js
vendored
@ -10,21 +10,20 @@ export default function generateTypeDefinition({ paradigm, table, query, typeDef
|
|||||||
const fields = table.fields;
|
const fields = table.fields;
|
||||||
function typeMap(schemaType) {
|
function typeMap(schemaType) {
|
||||||
if (schemaType.options && schemaType.options.length > 0) {
|
if (schemaType.options && schemaType.options.length > 0) {
|
||||||
return schemaType.options
|
let opts = schemaType.options.map((opt) => schemaType.dataType?.match(/int/i) || typeof opt == "number"
|
||||||
.map((opt) => schemaType.dataType?.match(/int/i) ||
|
|
||||||
typeof opt == "number"
|
|
||||||
? `${opt}`
|
? `${opt}`
|
||||||
: `"${opt}"`)
|
: `"${opt}"`);
|
||||||
.join(" | ");
|
opts.push(`""`);
|
||||||
|
return opts.join(" | ");
|
||||||
}
|
}
|
||||||
if (schemaType.dataType?.match(/blob/i)) {
|
if (schemaType.dataType?.match(/blob/i)) {
|
||||||
return "Float32Array<ArrayBuffer> | Buffer<ArrayBuffer>";
|
return `Float32Array<ArrayBuffer> | Buffer<ArrayBuffer> | null`;
|
||||||
}
|
}
|
||||||
if (schemaType.dataType?.match(/int|double|decimal|real/i)) {
|
if (schemaType.dataType?.match(/int|double|decimal|real/i)) {
|
||||||
return "number";
|
return `number | ""`;
|
||||||
}
|
}
|
||||||
if (schemaType.dataType?.match(/text|varchar|timestamp/i)) {
|
if (schemaType.dataType?.match(/text|varchar|timestamp/i)) {
|
||||||
return "string";
|
return `string`;
|
||||||
}
|
}
|
||||||
if (schemaType.dataType?.match(/boolean/i)) {
|
if (schemaType.dataType?.match(/boolean/i)) {
|
||||||
return "0 | 1";
|
return "0 | 1";
|
||||||
|
|||||||
2
dist/utils/sql-insert-generator.js
vendored
2
dist/utils/sql-insert-generator.js
vendored
@ -29,7 +29,7 @@ export default function sqlInsertGenerator({ tableName, data, dbFullName, }) {
|
|||||||
? value
|
? value
|
||||||
: null;
|
: null;
|
||||||
if (!finalValue) {
|
if (!finalValue) {
|
||||||
queryValues.push("");
|
queryValues.push(null);
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
queryValues.push(finalValue);
|
queryValues.push(finalValue);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/bun-sqlite",
|
"name": "@moduletrace/bun-sqlite",
|
||||||
"version": "1.0.40",
|
"version": "1.0.41",
|
||||||
"description": "SQLite manager for Bun",
|
"description": "SQLite manager for Bun",
|
||||||
"author": "Benjamin Toby",
|
"author": "Benjamin Toby",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@ -36,26 +36,27 @@ export default function generateTypeDefinition({
|
|||||||
|
|
||||||
function typeMap(schemaType: BUN_SQLITE_FieldSchemaType) {
|
function typeMap(schemaType: BUN_SQLITE_FieldSchemaType) {
|
||||||
if (schemaType.options && schemaType.options.length > 0) {
|
if (schemaType.options && schemaType.options.length > 0) {
|
||||||
return schemaType.options
|
let opts = schemaType.options.map((opt) =>
|
||||||
.map((opt) =>
|
schemaType.dataType?.match(/int/i) || typeof opt == "number"
|
||||||
schemaType.dataType?.match(/int/i) ||
|
? `${opt}`
|
||||||
typeof opt == "number"
|
: `"${opt}"`,
|
||||||
? `${opt}`
|
);
|
||||||
: `"${opt}"`,
|
|
||||||
)
|
opts.push(`""`);
|
||||||
.join(" | ");
|
|
||||||
|
return opts.join(" | ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schemaType.dataType?.match(/blob/i)) {
|
if (schemaType.dataType?.match(/blob/i)) {
|
||||||
return "Float32Array<ArrayBuffer> | Buffer<ArrayBuffer>";
|
return `Float32Array<ArrayBuffer> | Buffer<ArrayBuffer> | null`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schemaType.dataType?.match(/int|double|decimal|real/i)) {
|
if (schemaType.dataType?.match(/int|double|decimal|real/i)) {
|
||||||
return "number";
|
return `number | ""`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schemaType.dataType?.match(/text|varchar|timestamp/i)) {
|
if (schemaType.dataType?.match(/text|varchar|timestamp/i)) {
|
||||||
return "string";
|
return `string`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schemaType.dataType?.match(/boolean/i)) {
|
if (schemaType.dataType?.match(/boolean/i)) {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export default function sqlInsertGenerator({
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!finalValue) {
|
if (!finalValue) {
|
||||||
queryValues.push("");
|
queryValues.push(null);
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user