@mikro-orm/sql 7.3.0-dev.24 → 7.3.0-dev.26
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.d.ts +0 -6
- package/AbstractSqlDriver.js +6 -24
- package/README.md +4 -0
- package/package.json +3 -3
- package/query/QueryBuilder.js +8 -2
package/AbstractSqlDriver.d.ts
CHANGED
|
@@ -77,12 +77,6 @@ export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlCo
|
|
|
77
77
|
nativeUpdate<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T> & UpsertOptions<T>): Promise<QueryResult<T>>;
|
|
78
78
|
nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>, transform?: (sql: string, params: any[]) => string): Promise<QueryResult<T>>;
|
|
79
79
|
nativeDelete<T extends object>(entityName: EntityName<T>, where: FilterQuery<T> | string | any, options?: DeleteOptions<T>): Promise<QueryResult<T>>;
|
|
80
|
-
/**
|
|
81
|
-
* Fast comparison for collection snapshots that are represented by PK arrays.
|
|
82
|
-
* Compares scalars via `===` and fallbacks to Utils.equals()` for more complex types like Buffer.
|
|
83
|
-
* Always expects the same length of the arrays, since we only compare PKs of the same entity type.
|
|
84
|
-
*/
|
|
85
|
-
private comparePrimaryKeyArrays;
|
|
86
80
|
syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
|
|
87
81
|
loadFromPivotTable<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where?: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>, pivotJoin?: boolean): Promise<Dictionary<T[]>>;
|
|
88
82
|
/**
|
package/AbstractSqlDriver.js
CHANGED
|
@@ -1262,26 +1262,6 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
1262
1262
|
qb.setAbortOptions(pickAbortOptions(options));
|
|
1263
1263
|
return this.rethrow(qb.execute('run', false));
|
|
1264
1264
|
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Fast comparison for collection snapshots that are represented by PK arrays.
|
|
1267
|
-
* Compares scalars via `===` and fallbacks to Utils.equals()` for more complex types like Buffer.
|
|
1268
|
-
* Always expects the same length of the arrays, since we only compare PKs of the same entity type.
|
|
1269
|
-
*/
|
|
1270
|
-
comparePrimaryKeyArrays(a, b) {
|
|
1271
|
-
for (let i = a.length; i-- !== 0;) {
|
|
1272
|
-
if (['number', 'string', 'bigint', 'boolean'].includes(typeof a[i])) {
|
|
1273
|
-
if (a[i] !== b[i]) {
|
|
1274
|
-
return false;
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
else {
|
|
1278
|
-
if (!Utils.equals(a[i], b[i])) {
|
|
1279
|
-
return false;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
return true;
|
|
1284
|
-
}
|
|
1285
1265
|
async syncCollections(collections, options) {
|
|
1286
1266
|
const groups = {};
|
|
1287
1267
|
for (const coll of collections) {
|
|
@@ -1289,7 +1269,6 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
1289
1269
|
const meta = wrapped.__meta;
|
|
1290
1270
|
const pks = wrapped.getPrimaryKeys(true);
|
|
1291
1271
|
const snap = coll.getSnapshot();
|
|
1292
|
-
const includes = (arr, item) => !!arr.find(i => this.comparePrimaryKeyArrays(i, item));
|
|
1293
1272
|
// For union-target polymorphic M:N, prepend the per-row discriminator value so the pivot
|
|
1294
1273
|
// persister can write it alongside the FK id. Memoized per sync-run because a collection can
|
|
1295
1274
|
// hold hundreds of items of the same few types, and findDiscriminatorValue walks the prototype
|
|
@@ -1313,9 +1292,12 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
1313
1292
|
};
|
|
1314
1293
|
const snapshot = snap ? snap.map(toDiff) : [];
|
|
1315
1294
|
const current = coll.getItems(false).map(toDiff);
|
|
1316
|
-
const
|
|
1317
|
-
const
|
|
1318
|
-
const
|
|
1295
|
+
const hash = (item) => Utils.getPrimaryKeyHash(item);
|
|
1296
|
+
const currentKeys = new Set(current.map(hash));
|
|
1297
|
+
const snapshotKeys = new Set(snapshot.map(hash));
|
|
1298
|
+
const deleteDiff = snap ? snapshot.filter(item => !currentKeys.has(hash(item))) : true;
|
|
1299
|
+
const insertDiff = current.filter(item => !snapshotKeys.has(hash(item)));
|
|
1300
|
+
const target = snapshot.filter(item => currentKeys.has(hash(item))).concat(...insertDiff);
|
|
1319
1301
|
const equals = Utils.equals(current, target);
|
|
1320
1302
|
// wrong order if we just delete and insert to the end (only owning sides can have fixed order)
|
|
1321
1303
|
if (coll.property.owner && coll.property.fixedOrder && !equals && Array.isArray(deleteDiff)) {
|
package/README.md
CHANGED
|
@@ -201,6 +201,10 @@ You can find example integrations for some popular frameworks in the [`mikro-orm
|
|
|
201
201
|
|
|
202
202
|
- [Express + SQLite](https://github.com/mikro-orm/express-js-example-app)
|
|
203
203
|
|
|
204
|
+
## Supported Versions
|
|
205
|
+
|
|
206
|
+
New features and bug fixes land in the latest major version. The previous major version keeps receiving fixes for high and critical severity vulnerabilities for 12 months after the next major is released, and reaches end of life after that. See the [security policy](SECURITY.md) for the current status of each version and for how to report a vulnerability.
|
|
207
|
+
|
|
204
208
|
## Contributing
|
|
205
209
|
|
|
206
210
|
Contributions, issues and feature requests are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.3.0-dev.
|
|
3
|
+
"version": "7.3.0-dev.26",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"kysely": "0.29.9"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.2.
|
|
53
|
+
"@mikro-orm/core": "^7.2.12"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.3.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.3.0-dev.26"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/query/QueryBuilder.js
CHANGED
|
@@ -410,13 +410,19 @@ export class QueryBuilder {
|
|
|
410
410
|
* @internal
|
|
411
411
|
*/
|
|
412
412
|
async applyJoinedFilters(em, filterOptions) {
|
|
413
|
+
const joins = Object.values(this.#state.joins);
|
|
413
414
|
for (const path of this.#state.autoJoinedPaths) {
|
|
414
415
|
const join = this.getJoinForPath(path);
|
|
415
416
|
if (join.type === JoinType.pivotJoin) {
|
|
416
417
|
continue;
|
|
417
418
|
}
|
|
418
|
-
|
|
419
|
-
|
|
419
|
+
// nested joins inherit the overrides of their ancestor relations
|
|
420
|
+
const chain = [join];
|
|
421
|
+
for (let parent; (parent = joins.find(j => j.alias === chain[0].ownerAlias));) {
|
|
422
|
+
chain.unshift(parent);
|
|
423
|
+
}
|
|
424
|
+
const joinFilters = chain.reduce((acc, j) => QueryHelper.mergePropertyFilters(j.prop.filters, acc), filterOptions);
|
|
425
|
+
let cond = await em.applyFilters(join.prop.targetMeta.class, join.cond, joinFilters, 'read');
|
|
420
426
|
const criteriaNode = CriteriaNodeFactory.createNode(this.metadata, join.prop.targetMeta.class, cond);
|
|
421
427
|
cond = criteriaNode.process(this, {
|
|
422
428
|
matchPopulateJoins: true,
|