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.
@@ -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 = modelNames[j];
149
- let info = modelInfo[modelName];
150
- let models = modelData[modelName];
151
- let model = data[modelName];
152
- let pkFieldName = info.pkFieldName;
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mythix-orm-sql-base",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "SQL base support for Mythix ORM",
5
5
  "main": "lib/index",
6
6
  "type": "commonjs",