@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.cjs
CHANGED
|
@@ -5538,6 +5538,7 @@ var QueryNameMapper = class extends kysely.OperationNodeTransformer {
|
|
|
5538
5538
|
modelToTableMap = /* @__PURE__ */ new Map();
|
|
5539
5539
|
fieldToColumnMap = /* @__PURE__ */ new Map();
|
|
5540
5540
|
enumTypeMap = /* @__PURE__ */ new Map();
|
|
5541
|
+
joinTableSchemaMap = /* @__PURE__ */ new Map();
|
|
5541
5542
|
scopes = [];
|
|
5542
5543
|
dialect;
|
|
5543
5544
|
constructor(client) {
|
|
@@ -5556,6 +5557,13 @@ var QueryNameMapper = class extends kysely.OperationNodeTransformer {
|
|
|
5556
5557
|
const mappedName = this.getMappedName(enumDef);
|
|
5557
5558
|
if (mappedName) this.enumTypeMap.set(enumName, mappedName);
|
|
5558
5559
|
}
|
|
5560
|
+
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 })) {
|
|
5561
|
+
const m2m = getManyToManyRelation(this.schema, modelName, fieldDef.name);
|
|
5562
|
+
if (m2m && !this.joinTableSchemaMap.has(m2m.joinTable)) {
|
|
5563
|
+
const owningModel = [modelName, m2m.otherModel].sort()[0];
|
|
5564
|
+
this.joinTableSchemaMap.set(m2m.joinTable, this.getTableSchema(owningModel) ?? "public");
|
|
5565
|
+
}
|
|
5566
|
+
}
|
|
5559
5567
|
}
|
|
5560
5568
|
get schema() {
|
|
5561
5569
|
return this.client.$schema;
|
|
@@ -5819,8 +5827,9 @@ var QueryNameMapper = class extends kysely.OperationNodeTransformer {
|
|
|
5819
5827
|
}
|
|
5820
5828
|
getTableSchema(model) {
|
|
5821
5829
|
if (this.schema.provider.type !== "postgresql") return;
|
|
5830
|
+
if (!this.schema.models[model]) return this.joinTableSchemaMap.get(model) ?? "public";
|
|
5822
5831
|
let schema = this.schema.provider.defaultSchema ?? "public";
|
|
5823
|
-
const schemaAttr = this.schema.models[model]
|
|
5832
|
+
const schemaAttr = this.schema.models[model].attributes?.find((attr) => attr.name === "@@schema");
|
|
5824
5833
|
if (schemaAttr) {
|
|
5825
5834
|
const mapArg = schemaAttr.args?.find((arg) => arg.name === "map");
|
|
5826
5835
|
if (mapArg && mapArg.value.kind === "literal") schema = mapArg.value.value;
|