mythix-orm-sql-base 1.7.3 → 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 +30 -5
- package/package.json +1 -1
|
@@ -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)
|