proto.io 0.0.169 → 0.0.171
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.
|
@@ -2262,16 +2262,24 @@ const encodeFieldExpression = (compiler, parent, field, expr) => {
|
|
|
2262
2262
|
}[expr.type];
|
|
2263
2263
|
if (!_.isArray(expr.value))
|
|
2264
2264
|
break;
|
|
2265
|
-
if (_.isEmpty(expr.value))
|
|
2266
|
-
|
|
2265
|
+
if (_.isEmpty(expr.value)) {
|
|
2266
|
+
switch (expr.type) {
|
|
2267
|
+
case '$superset': return sql `true`;
|
|
2268
|
+
case '$intersect': return sql `false`;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2267
2271
|
if (dataType === 'array' || (!_.isString(dataType) && dataType?.type === 'array')) {
|
|
2268
2272
|
return sql `${element} ${{ literal: op }} ${{ value: _encodeValue(expr.value) }}`;
|
|
2269
2273
|
}
|
|
2270
2274
|
if (relation && parent.className) {
|
|
2271
2275
|
if (!_.every(expr.value, x => x instanceof TObject && x.objectId))
|
|
2272
2276
|
break;
|
|
2277
|
+
const tempName = `_populate_expr_$${compiler.nextIdx()}`;
|
|
2273
2278
|
const populate = _selectRelationPopulate(compiler, { className: parent.className, name: parent.name }, relation.populate, `$${field}`, false);
|
|
2274
|
-
return sql `ARRAY(
|
|
2279
|
+
return sql `ARRAY(
|
|
2280
|
+
SELECT ${{ identifier: '_id' }}
|
|
2281
|
+
FROM (${populate}) AS ${{ identifier: tempName }}
|
|
2282
|
+
) ${{ literal: op }} ARRAY[${_.map(expr.value, (x) => sql `${{ value: x.objectId }}`)}]::TEXT[]`;
|
|
2275
2283
|
}
|
|
2276
2284
|
if (!dataType) {
|
|
2277
2285
|
return sql `jsonb_typeof(${element}) ${nullSafeEqual()} 'array' AND ${element} ${{ literal: op }} ${_encodeJsonValue(_encodeValue(expr.value))}`;
|