@cadenza.io/service 1.6.3 → 1.6.5

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
@@ -2586,7 +2586,7 @@ CREATE TRIGGER prevent_modification BEFORE UPDATE OR DELETE ON ${tableName} FOR
2586
2586
  for (const field of Object.values(table.fields)) {
2587
2587
  if (field.references) {
2588
2588
  const [refTable] = field.references.split(".");
2589
- if (allTables.includes(refTable)) {
2589
+ if (refTable !== tableName && allTables.includes(refTable)) {
2590
2590
  (_a2 = graph.get(refTable)) == null ? void 0 : _a2.add(tableName);
2591
2591
  }
2592
2592
  }
@@ -2595,10 +2595,11 @@ CREATE TRIGGER prevent_modification BEFORE UPDATE OR DELETE ON ${tableName} FOR
2595
2595
  const visited = /* @__PURE__ */ new Set();
2596
2596
  const tempMark = /* @__PURE__ */ new Set();
2597
2597
  const sorted = [];
2598
+ let hasCycles = false;
2598
2599
  function visit(table) {
2599
2600
  if (tempMark.has(table)) {
2600
- console.log("Circular reference detected involving table", table);
2601
- throw new Error(`Circular reference detected involving table ${table}`);
2601
+ hasCycles = true;
2602
+ return;
2602
2603
  }
2603
2604
  if (visited.has(table)) return;
2604
2605
  tempMark.add(table);
@@ -2614,7 +2615,13 @@ CREATE TRIGGER prevent_modification BEFORE UPDATE OR DELETE ON ${tableName} FOR
2614
2615
  visit(table);
2615
2616
  }
2616
2617
  }
2617
- return __spreadProps(__spreadValues({}, ctx), { sortedTables: sorted });
2618
+ for (const table of allTables) {
2619
+ if (!visited.has(table)) {
2620
+ sorted.push(table);
2621
+ }
2622
+ }
2623
+ console.log("sorted tables", sorted, "has cycles", hasCycles);
2624
+ return __spreadProps(__spreadValues({}, ctx), { sortedTables: sorted, hasCycles });
2618
2625
  }
2619
2626
  splitTables(ctx) {
2620
2627
  return __asyncGenerator(this, null, function* () {