@mikro-orm/knex 5.8.11-dev.14 → 5.8.11-dev.16
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "5.8.11-dev.
|
|
3
|
+
"version": "5.8.11-dev.16",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"@mikro-orm/core": "^5.8.10"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "5.8.11-dev.
|
|
70
|
-
"@mikro-orm/entity-generator": "5.8.11-dev.
|
|
71
|
-
"@mikro-orm/migrations": "5.8.11-dev.
|
|
69
|
+
"@mikro-orm/core": "5.8.11-dev.16",
|
|
70
|
+
"@mikro-orm/entity-generator": "5.8.11-dev.16",
|
|
71
|
+
"@mikro-orm/migrations": "5.8.11-dev.16",
|
|
72
72
|
"better-sqlite3": "*",
|
|
73
73
|
"mssql": "*",
|
|
74
74
|
"mysql": "*",
|
package/query/QueryBuilder.js
CHANGED
|
@@ -782,6 +782,8 @@ class QueryBuilder {
|
|
|
782
782
|
getQueryBase() {
|
|
783
783
|
const qb = this.getKnex();
|
|
784
784
|
const schema = this.getSchema(this.mainAlias);
|
|
785
|
+
// Joined tables doesn't need to belong to the same schema as the main table
|
|
786
|
+
const joinSchema = this._schema ?? this.em?.schema ?? schema;
|
|
785
787
|
if (schema) {
|
|
786
788
|
qb.withSchema(schema);
|
|
787
789
|
}
|
|
@@ -800,12 +802,12 @@ class QueryBuilder {
|
|
|
800
802
|
else if (this.flags.has(core_1.QueryFlag.DISTINCT)) {
|
|
801
803
|
qb.distinct();
|
|
802
804
|
}
|
|
803
|
-
this.helper.processJoins(qb, this._joins,
|
|
805
|
+
this.helper.processJoins(qb, this._joins, joinSchema);
|
|
804
806
|
break;
|
|
805
807
|
case enums_1.QueryType.COUNT: {
|
|
806
808
|
const m = this.flags.has(core_1.QueryFlag.DISTINCT) ? 'countDistinct' : 'count';
|
|
807
809
|
qb[m]({ count: this._fields.map(f => this.helper.mapper(f, this.type)) });
|
|
808
|
-
this.helper.processJoins(qb, this._joins,
|
|
810
|
+
this.helper.processJoins(qb, this._joins, joinSchema);
|
|
809
811
|
break;
|
|
810
812
|
}
|
|
811
813
|
case enums_1.QueryType.INSERT:
|
|
@@ -998,7 +1000,7 @@ class QueryBuilder {
|
|
|
998
1000
|
getSchema(alias) {
|
|
999
1001
|
const { metadata } = alias;
|
|
1000
1002
|
const metaSchema = metadata?.schema && metadata.schema !== '*' ? metadata.schema : undefined;
|
|
1001
|
-
return this._schema ?? metaSchema ?? this.em?.config.get('schema');
|
|
1003
|
+
return this._schema ?? metaSchema ?? this.em?.schema ?? this.em?.config.get('schema');
|
|
1002
1004
|
}
|
|
1003
1005
|
createAlias(entityName, aliasName, subQuery) {
|
|
1004
1006
|
const metadata = this.metadata.find(entityName);
|
|
@@ -133,7 +133,7 @@ class QueryBuilderHelper {
|
|
|
133
133
|
return {
|
|
134
134
|
prop, type, cond, ownerAlias, alias,
|
|
135
135
|
table: this.getTableName(prop.type),
|
|
136
|
-
schema: this.driver.getSchemaName(prop.targetMeta),
|
|
136
|
+
schema: prop.targetMeta?.schema === '*' ? '*' : this.driver.getSchemaName(prop.targetMeta),
|
|
137
137
|
joinColumns: prop.referencedColumnNames,
|
|
138
138
|
primaryKeys: prop.fieldNames,
|
|
139
139
|
};
|
|
@@ -150,7 +150,7 @@ class QueryBuilderHelper {
|
|
|
150
150
|
primaryKeys: prop.referencedColumnNames,
|
|
151
151
|
cond: {},
|
|
152
152
|
table: pivotMeta.tableName,
|
|
153
|
-
schema: this.driver.getSchemaName(pivotMeta),
|
|
153
|
+
schema: prop.targetMeta?.schema === '*' ? '*' : this.driver.getSchemaName(pivotMeta),
|
|
154
154
|
path: path.endsWith('[pivot]') ? path : `${path}[pivot]`,
|
|
155
155
|
},
|
|
156
156
|
};
|