@prisma/orm-family-sql 8.0.0-rc.18-dev.44 → 8.0.0-rc.18-dev.46

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.
@@ -9,7 +9,7 @@ import { t as createFunctions } from "./functions-0YWByawj.mjs";
9
9
  import { t as createIndexReferences } from "./index-reference-DR62gjQS.mjs";
10
10
  import { o as settlementOf } from "./transaction-state-BfXhs7D7-3k10jZ8I.mjs";
11
11
  import { m as findActivitySource } from "./exports-D3JbXqm_-mm-wWICO.mjs";
12
- import { structuredError } from "@prisma/orm-framework/utils/structured-error";
12
+ import { isStructuredError, structuredError } from "@prisma/orm-framework/utils/structured-error";
13
13
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
14
14
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
15
15
  import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -334,12 +334,15 @@ function resolveVariantFieldColumns(contract, namespaceId, baseModelName, varian
334
334
  if (variant?.strategy !== "mti") return {};
335
335
  return Object.fromEntries(Object.entries(getModelFields(contract, variant.namespaceId, variant.modelName)).filter(([, field]) => field.namespaceId === variant.namespaceId && field.table === variant.table));
336
336
  }
337
+ function isTableAmbiguousError(error) {
338
+ return isStructuredError(error) && error.code === "CONTRACT.TABLE_AMBIGUOUS";
339
+ }
337
340
  /** Every column of a table, in table order. */
338
341
  function getAllTableColumns(contract, namespaceId, tableName) {
339
342
  try {
340
343
  return Object.keys(storageTableForContract(contract, namespaceId, tableName).columns);
341
344
  } catch (error) {
342
- if (error instanceof Error && error.message.includes("ambiguous")) throw error;
345
+ if (isTableAmbiguousError(error)) throw error;
343
346
  throw ormError("ORM.TABLE_UNKNOWN", `Unknown table "${tableName}" in SQL ORM query planner`, { meta: {
344
347
  namespaceId,
345
348
  tableName
@@ -511,7 +514,7 @@ function resolveRowIdentityColumns(contract, namespaceId, tableName) {
511
514
  try {
512
515
  table = storageTableForContract(contract, namespaceId, tableName);
513
516
  } catch (error) {
514
- if (error instanceof Error && error.message.includes("ambiguous")) throw error;
517
+ if (isTableAmbiguousError(error)) throw error;
515
518
  return [];
516
519
  }
517
520
  if (table.primaryKey && table.primaryKey.columns.length > 0) return table.primaryKey.columns;