mythix-orm 1.5.0 → 1.5.1
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.
|
@@ -68,8 +68,9 @@ class QueryEngine extends QueryEngineBase {
|
|
|
68
68
|
if (!QueryEngine.isQuery(queryEngine) && Nife.instanceOf(queryEngine, 'array', 'object', 'map', 'set'))
|
|
69
69
|
queryEngine = Utils.generateQueryFromFilter(this.getConnection(), thisQueryContext.rootModel, queryEngine);
|
|
70
70
|
|
|
71
|
-
let sourceQuery
|
|
72
|
-
let currentModel
|
|
71
|
+
let sourceQuery = queryEngine._getRawQuery();
|
|
72
|
+
let currentModel = thisQueryContext.Model;
|
|
73
|
+
let skipLogicalOperators = true;
|
|
73
74
|
|
|
74
75
|
for (let i = 0, il = sourceQuery.length; i < il; i++) {
|
|
75
76
|
let queryPart = sourceQuery[i];
|
|
@@ -88,12 +89,29 @@ class QueryEngine extends QueryEngineBase {
|
|
|
88
89
|
'rootModelName',
|
|
89
90
|
]);
|
|
90
91
|
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
// For merges, we want to skip the first logical operators
|
|
93
|
+
// found before any other operation.
|
|
94
|
+
// This is because one might do a: Model.where.OR.MERGE(Model.AND.field.EQ()).
|
|
95
|
+
// This query, once merged, would be: Model.where.OR.Model.AND.field.EQ(),
|
|
96
|
+
// which is not what we want... instead we want: Model.where.OR.Model.field.EQ().
|
|
97
|
+
// Since the result we want here is OR merge, not AND merge
|
|
98
|
+
// we skip the first "AND" we encounter, leaving the "OR" as
|
|
99
|
+
// the current logical operator.
|
|
100
|
+
if (skipLogicalOperators && Object.prototype.hasOwnProperty.call(mergeContext, 'logical') && mergeContext.logical) {
|
|
101
|
+
if (mergeContext.value == null && (mergeContext.operator === 'AND' || mergeContext.operator === 'OR'))
|
|
94
102
|
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (Object.prototype.hasOwnProperty.call(mergeContext, 'operator')) {
|
|
106
|
+
// Skip unneeded duplicate model entries
|
|
107
|
+
if (mergeContext.operator === 'MODEL') {
|
|
108
|
+
if (mergeContext.Model === currentModel)
|
|
109
|
+
continue;
|
|
95
110
|
|
|
96
|
-
|
|
111
|
+
currentModel = mergeContext.Model;
|
|
112
|
+
} else if (mergeContext.operator !== 'FIELD') {
|
|
113
|
+
skipLogicalOperators = false;
|
|
114
|
+
}
|
|
97
115
|
}
|
|
98
116
|
|
|
99
117
|
this._addToQuery(Object.assign({
|