proto.io 0.0.170 → 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,8 +2262,12 @@ 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
- return sql `true`;
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
  }
@@ -2275,7 +2279,7 @@ const encodeFieldExpression = (compiler, parent, field, expr) => {
2275
2279
  return sql `ARRAY(
2276
2280
  SELECT ${{ identifier: '_id' }}
2277
2281
  FROM (${populate}) AS ${{ identifier: tempName }}
2278
- ) ${{ literal: op }} ARRAY[${_.map(expr.value, (x) => sql `${{ value: x.objectId }}`)}]`;
2282
+ ) ${{ literal: op }} ARRAY[${_.map(expr.value, (x) => sql `${{ value: x.objectId }}`)}]::TEXT[]`;
2279
2283
  }
2280
2284
  if (!dataType) {
2281
2285
  return sql `jsonb_typeof(${element}) ${nullSafeEqual()} 'array' AND ${element} ${{ literal: op }} ${_encodeJsonValue(_encodeValue(expr.value))}`;