@mikro-orm/sql 7.2.12-dev.0 → 7.2.12-dev.2
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/package.json +2 -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.12-dev.
|
|
3
|
+
"version": "7.2.12-dev.2",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.2.11"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.12-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.12-dev.2"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|