@dbsp/core 1.3.0 → 1.4.0

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/dist/index.js CHANGED
@@ -6163,7 +6163,10 @@ import {
6163
6163
  NqlLexer,
6164
6164
  compile as nqlCompile
6165
6165
  } from "@dbsp/nql";
6166
- import { NQL_INTERNAL_COMPILER_OPTIONS } from "@dbsp/types/internal";
6166
+ import {
6167
+ getTrustedNqlRelationFilterFields,
6168
+ NQL_INTERNAL_COMPILER_OPTIONS
6169
+ } from "@dbsp/types/internal";
6167
6170
  var NQL_RAW_FRAGMENT = /* @__PURE__ */ Symbol("NqlRawFragment");
6168
6171
  function hasNqlBindings(bundle) {
6169
6172
  return (bundle.bindings?.size ?? 0) > 0;
@@ -6186,6 +6189,9 @@ function findBindingFinalRelationFilter(where) {
6186
6189
  case "not":
6187
6190
  return findBindingFinalRelationFilter(where.condition);
6188
6191
  case "relationFilter":
6192
+ if (getTrustedNqlRelationFilterFields(where) !== void 0) {
6193
+ return void 0;
6194
+ }
6189
6195
  return formatBindingRelationPath(where.relation);
6190
6196
  case "exists":
6191
6197
  case "notExists":
@@ -6198,7 +6204,14 @@ function findBindingFinalRelationFilter(where) {
6198
6204
  }
6199
6205
  }
6200
6206
  function assertBindingFinalQueryCanUseSyntheticPlan(intent) {
6201
- const relationColumns = intent.select?.type === "expressions" ? intent.select.columns.filter((column) => column.kind === "relationColumn").map((column) => column.relation) : [];
6207
+ const relationColumns = intent.select?.type === "expressions" ? intent.select.columns.flatMap((column) => {
6208
+ if (column.kind !== "relationColumn") return [];
6209
+ const trusted = getTrustedNqlRelationFilterFields(column);
6210
+ if (trusted?.selectedColumn !== void 0 && trusted.cardinality === "one") {
6211
+ return [];
6212
+ }
6213
+ return [column.relation];
6214
+ }) : [];
6202
6215
  const relationFilter = intent.where ? findBindingFinalRelationFilter(intent.where) : void 0;
6203
6216
  const havingRelationFilter = intent.having ? findBindingFinalRelationFilter(intent.having) : void 0;
6204
6217
  if ((intent.include?.length ?? 0) > 0 || relationColumns.length > 0 || (intent.joins?.length ?? 0) > 0 || relationFilter !== void 0 || havingRelationFilter !== void 0) {