@mikro-orm/knex 5.7.15-dev.31 → 5.7.15-dev.33
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/AbstractSqlDriver.js +17 -11
- package/package.json +4 -4
- package/query/QueryBuilder.js +4 -0
- package/query/QueryBuilderHelper.js +3 -2
package/AbstractSqlDriver.js
CHANGED
|
@@ -461,11 +461,23 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
461
461
|
if (coll.property.reference === core_1.ReferenceType.ONE_TO_MANY) {
|
|
462
462
|
const cols = coll.property.referencedColumnNames;
|
|
463
463
|
const qb = this.createQueryBuilder(coll.property.type, ctx, 'write')
|
|
464
|
-
.withSchema(this.getSchemaName(meta, options))
|
|
465
|
-
|
|
464
|
+
.withSchema(this.getSchemaName(meta, options));
|
|
465
|
+
if (coll.getSnapshot() === undefined) {
|
|
466
|
+
if (coll.property.orphanRemoval) {
|
|
467
|
+
const kqb = qb.delete({ [coll.property.mappedBy]: pks })
|
|
468
|
+
.getKnexQuery()
|
|
469
|
+
.whereNotIn(cols, insertDiff);
|
|
470
|
+
return this.rethrow(this.execute(kqb));
|
|
471
|
+
}
|
|
472
|
+
const kqb = qb.update({ [coll.property.mappedBy]: null })
|
|
473
|
+
.getKnexQuery()
|
|
474
|
+
.whereNotIn(cols, insertDiff);
|
|
475
|
+
return this.rethrow(this.execute(kqb));
|
|
476
|
+
}
|
|
477
|
+
const kqb = qb.update({ [coll.property.mappedBy]: pks })
|
|
466
478
|
.getKnexQuery()
|
|
467
479
|
.whereIn(cols, insertDiff);
|
|
468
|
-
return this.rethrow(this.execute(
|
|
480
|
+
return this.rethrow(this.execute(kqb));
|
|
469
481
|
}
|
|
470
482
|
/* istanbul ignore next */
|
|
471
483
|
const ownerSchema = wrapped.getSchema() === '*' ? this.config.get('schema') : wrapped.getSchema();
|
|
@@ -754,7 +766,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
754
766
|
}
|
|
755
767
|
if (prop.reference === core_1.ReferenceType.EMBEDDED) {
|
|
756
768
|
if (prop.object) {
|
|
757
|
-
ret.push(prop.
|
|
769
|
+
ret.push(prop.name);
|
|
758
770
|
return;
|
|
759
771
|
}
|
|
760
772
|
const parts = field.split('.');
|
|
@@ -766,13 +778,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
766
778
|
}
|
|
767
779
|
return;
|
|
768
780
|
}
|
|
769
|
-
|
|
770
|
-
ret.push(prop.name);
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
if (prop.fieldNames) {
|
|
774
|
-
ret.push(...prop.fieldNames);
|
|
775
|
-
}
|
|
781
|
+
ret.push(prop.name);
|
|
776
782
|
}
|
|
777
783
|
buildFields(meta, populate, joinedProps, qb, fields) {
|
|
778
784
|
const lazyProps = meta.props.filter(prop => prop.lazy && !populate.some(p => p.field === prop.name || p.all));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "5.7.15-dev.
|
|
3
|
+
"version": "5.7.15-dev.33",
|
|
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.7.14"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "~5.7.15-dev.
|
|
70
|
-
"@mikro-orm/entity-generator": "~5.7.15-dev.
|
|
71
|
-
"@mikro-orm/migrations": "~5.7.15-dev.
|
|
69
|
+
"@mikro-orm/core": "~5.7.15-dev.33",
|
|
70
|
+
"@mikro-orm/entity-generator": "~5.7.15-dev.33",
|
|
71
|
+
"@mikro-orm/migrations": "~5.7.15-dev.33",
|
|
72
72
|
"better-sqlite3": "*",
|
|
73
73
|
"mssql": "*",
|
|
74
74
|
"mysql": "*",
|
package/query/QueryBuilder.js
CHANGED
|
@@ -686,6 +686,10 @@ class QueryBuilder {
|
|
|
686
686
|
}
|
|
687
687
|
return;
|
|
688
688
|
}
|
|
689
|
+
if (prop && prop.fieldNames.length > 1) {
|
|
690
|
+
ret.push(...prop.fieldNames.map(f => this.helper.mapper(f, this.type)));
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
689
693
|
ret.push(this.helper.mapper(field, this.type));
|
|
690
694
|
});
|
|
691
695
|
const meta = this.mainAlias.metadata;
|
|
@@ -128,12 +128,13 @@ class QueryBuilderHelper {
|
|
|
128
128
|
const pivotMeta = this.metadata.find(prop.pivotEntity);
|
|
129
129
|
const ret = {
|
|
130
130
|
[`${ownerAlias}.${prop.name}#${pivotAlias}`]: {
|
|
131
|
-
prop, type,
|
|
131
|
+
prop, type, ownerAlias,
|
|
132
132
|
alias: pivotAlias,
|
|
133
133
|
inverseAlias: alias,
|
|
134
134
|
joinColumns: prop.joinColumns,
|
|
135
135
|
inverseJoinColumns: prop.inverseJoinColumns,
|
|
136
136
|
primaryKeys: prop.referencedColumnNames,
|
|
137
|
+
cond: {},
|
|
137
138
|
table: pivotMeta.tableName,
|
|
138
139
|
schema: this.driver.getSchemaName(pivotMeta),
|
|
139
140
|
path: path.endsWith('[pivot]') ? path : `${path}[pivot]`,
|
|
@@ -143,7 +144,7 @@ class QueryBuilderHelper {
|
|
|
143
144
|
return ret;
|
|
144
145
|
}
|
|
145
146
|
const prop2 = prop.owner ? pivotMeta.relations[1] : pivotMeta.relations[0];
|
|
146
|
-
ret[`${pivotAlias}.${prop2.name}#${alias}`] = this.joinManyToOneReference(prop2, pivotAlias, alias, type);
|
|
147
|
+
ret[`${pivotAlias}.${prop2.name}#${alias}`] = this.joinManyToOneReference(prop2, pivotAlias, alias, type, cond);
|
|
147
148
|
ret[`${pivotAlias}.${prop2.name}#${alias}`].path = path;
|
|
148
149
|
return ret;
|
|
149
150
|
}
|