@zenstackhq/orm 3.6.1 → 3.6.3-beta.1
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.cjs +10 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -5501,6 +5501,7 @@ var QueryNameMapper = class extends OperationNodeTransformer {
|
|
|
5501
5501
|
modelToTableMap = /* @__PURE__ */ new Map();
|
|
5502
5502
|
fieldToColumnMap = /* @__PURE__ */ new Map();
|
|
5503
5503
|
enumTypeMap = /* @__PURE__ */ new Map();
|
|
5504
|
+
joinTableSchemaMap = /* @__PURE__ */ new Map();
|
|
5504
5505
|
scopes = [];
|
|
5505
5506
|
dialect;
|
|
5506
5507
|
constructor(client) {
|
|
@@ -5519,6 +5520,13 @@ var QueryNameMapper = class extends OperationNodeTransformer {
|
|
|
5519
5520
|
const mappedName = this.getMappedName(enumDef);
|
|
5520
5521
|
if (mappedName) this.enumTypeMap.set(enumName, mappedName);
|
|
5521
5522
|
}
|
|
5523
|
+
if (client.$schema.provider.type === "postgresql") for (const modelName of Object.keys(client.$schema.models)) for (const fieldDef of getModelFields(this.schema, modelName, { relations: true })) {
|
|
5524
|
+
const m2m = getManyToManyRelation(this.schema, modelName, fieldDef.name);
|
|
5525
|
+
if (m2m && !this.joinTableSchemaMap.has(m2m.joinTable)) {
|
|
5526
|
+
const owningModel = [modelName, m2m.otherModel].sort()[0];
|
|
5527
|
+
this.joinTableSchemaMap.set(m2m.joinTable, this.getTableSchema(owningModel) ?? "public");
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5522
5530
|
}
|
|
5523
5531
|
get schema() {
|
|
5524
5532
|
return this.client.$schema;
|
|
@@ -5782,8 +5790,9 @@ var QueryNameMapper = class extends OperationNodeTransformer {
|
|
|
5782
5790
|
}
|
|
5783
5791
|
getTableSchema(model) {
|
|
5784
5792
|
if (this.schema.provider.type !== "postgresql") return;
|
|
5793
|
+
if (!this.schema.models[model]) return this.joinTableSchemaMap.get(model) ?? "public";
|
|
5785
5794
|
let schema = this.schema.provider.defaultSchema ?? "public";
|
|
5786
|
-
const schemaAttr = this.schema.models[model]
|
|
5795
|
+
const schemaAttr = this.schema.models[model].attributes?.find((attr) => attr.name === "@@schema");
|
|
5787
5796
|
if (schemaAttr) {
|
|
5788
5797
|
const mapArg = schemaAttr.args?.find((arg) => arg.name === "map");
|
|
5789
5798
|
if (mapArg && mapArg.value.kind === "literal") schema = mapArg.value.value;
|