@mlagie/sql-connector 1.0.7-beta → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -165,8 +165,9 @@ function generateCondition(filter, isUpdate = false, schema = null) {
|
|
|
165
165
|
|
|
166
166
|
function generateValueSQL(value) {
|
|
167
167
|
return value.map(item => {
|
|
168
|
+
if (item === null) return 'NULL';
|
|
168
169
|
if (typeof item === "string") return `"${item.replace(/"/g, '\\"')}"`;
|
|
169
|
-
if (typeof item === "object") return `"${item}"`;
|
|
170
|
+
if (typeof item === "object" && item !== null) return `"${item}"`;
|
|
170
171
|
return item;
|
|
171
172
|
}).join(", ");
|
|
172
173
|
}
|
|
@@ -349,13 +350,7 @@ class Model {
|
|
|
349
350
|
|
|
350
351
|
if (field.required) columnDefinition += ' NOT NULL';
|
|
351
352
|
if (field.default !== undefined && field.default != null) columnDefinition += ` DEFAULT "${field.default}"`;
|
|
352
|
-
if (field.default === null)
|
|
353
|
-
if (field.unique) {
|
|
354
|
-
columnDefinition += ` DEFAULT ${null}`;
|
|
355
|
-
} else {
|
|
356
|
-
columnDefinition += ` DEFAULT 'NULL'`;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
353
|
+
if (field.default === null) columnDefinition += ` DEFAULT NULL`;
|
|
359
354
|
if (field.unique) columnDefinition += ' UNIQUE';
|
|
360
355
|
if (field.auto_increment) columnDefinition += ' AUTO_INCREMENT';
|
|
361
356
|
if (field.foreignKey) foreignKey.push(`FOREIGN KEY (${fieldName}) REFERENCES ${field.foreignKey}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlagie/sql-connector",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Le module sql-connector permet de gérer les connexions à une base de données MySQL, de définir des schémas de tables, et d'interagir avec les données de manière simple et efficace.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|