mythix-orm-sql-base 1.7.2 → 1.7.4
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/lib/sql-connection-base.js +34 -6
- package/package.json +5 -5
|
@@ -85,6 +85,16 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
85
85
|
return (!parts.length) ? null : parts.join(',');
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const isEmptyModel = (model) => {
|
|
89
|
+
if (!model)
|
|
90
|
+
return true;
|
|
91
|
+
|
|
92
|
+
if (model._mythixIsEmpty === false)
|
|
93
|
+
return false;
|
|
94
|
+
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
|
|
88
98
|
let context = queryEngine._getRawQueryContext();
|
|
89
99
|
let fields = this.findAllFieldsFromFieldProjectionMap(columns);
|
|
90
100
|
let rootModelName = context.rootModelName;
|
|
@@ -140,16 +150,31 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
140
150
|
if (!dataContext)
|
|
141
151
|
dataContext = data[modelName] = {};
|
|
142
152
|
|
|
153
|
+
// Track empty models (can happen for left or right table joins)
|
|
154
|
+
if (remoteValue != null && !Object.prototype.hasOwnProperty.call(dataContext, '_mythixIsEmpty')) {
|
|
155
|
+
Object.defineProperties(dataContext, {
|
|
156
|
+
'_mythixIsEmpty': {
|
|
157
|
+
writable: true,
|
|
158
|
+
enumerable: false,
|
|
159
|
+
configurable: true,
|
|
160
|
+
value: false,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
143
165
|
dataContext[field.fieldName] = remoteValue;
|
|
144
166
|
}
|
|
145
167
|
|
|
146
168
|
let rootModel;
|
|
147
169
|
for (let j = 0, jl = modelNames.length; j < jl; j++) {
|
|
148
|
-
let modelName
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
let modelName = modelNames[j];
|
|
171
|
+
let model = data[modelName];
|
|
172
|
+
if (isEmptyModel(model))
|
|
173
|
+
continue;
|
|
174
|
+
|
|
175
|
+
let info = modelInfo[modelName];
|
|
176
|
+
let models = modelData[modelName];
|
|
177
|
+
let pkFieldName = info.pkFieldName;
|
|
153
178
|
let index;
|
|
154
179
|
|
|
155
180
|
if (!models)
|
|
@@ -413,6 +438,9 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
413
438
|
|
|
414
439
|
let options = _options || {};
|
|
415
440
|
if (_models == null) {
|
|
441
|
+
if (options.truncate !== true)
|
|
442
|
+
return;
|
|
443
|
+
|
|
416
444
|
let queryGenerator = this.getQueryGenerator();
|
|
417
445
|
let sqlStr = queryGenerator.generateDeleteStatement(Model, Model.where(this).unscoped(), options);
|
|
418
446
|
|
|
@@ -742,7 +770,7 @@ class SQLConnectionBase extends ConnectionBase {
|
|
|
742
770
|
|
|
743
771
|
async alterColumn(Field, newFieldAttributes, options) {
|
|
744
772
|
let queryGenerator = this.getQueryGenerator();
|
|
745
|
-
let sqlStatements = queryGenerator.
|
|
773
|
+
let sqlStatements = queryGenerator.generateAlterColumnStatements(Field, newFieldAttributes, options);
|
|
746
774
|
|
|
747
775
|
for (let i = 0, il = sqlStatements.length; i < il; i++) {
|
|
748
776
|
let sqlStr = sqlStatements[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mythix-orm-sql-base",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"description": "SQL base support for Mythix ORM",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/th317erd/mythix-orm-sql-base#readme",
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"mythix-orm": "^1.8.
|
|
36
|
+
"mythix-orm": "^1.8.3"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"luxon": "^3.0
|
|
39
|
+
"luxon": "^3.1.0",
|
|
40
40
|
"nife": "^1.12.1",
|
|
41
41
|
"uuid": "^9.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@spothero/eslint-plugin-spothero": "github:spothero/eslint-plugin-spothero",
|
|
45
45
|
"better-sqlite3": "^7.6.2",
|
|
46
|
-
"eslint": "^8.
|
|
47
|
-
"jasmine": "^4.
|
|
46
|
+
"eslint": "^8.27.0",
|
|
47
|
+
"jasmine": "^4.5.0",
|
|
48
48
|
"nyc": "^15.1.0"
|
|
49
49
|
},
|
|
50
50
|
"nyc": {
|