@mikro-orm/core 7.2.2-dev.3 → 7.2.2-dev.30
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/EntityManager.d.ts +6 -1
- package/EntityManager.js +81 -27
- package/entity/EntityFactory.d.ts +1 -0
- package/entity/EntityFactory.js +32 -3
- package/entity/EntityLoader.js +7 -6
- package/entity/WrappedEntity.js +6 -1
- package/entity/defineEntity.d.ts +1 -1
- package/entity/defineEntity.js +1 -1
- package/errors.d.ts +1 -0
- package/errors.js +3 -0
- package/hydration/ObjectHydrator.js +2 -2
- package/metadata/MetadataDiscovery.d.ts +2 -0
- package/metadata/MetadataDiscovery.js +38 -5
- package/metadata/MetadataStorage.d.ts +7 -0
- package/metadata/MetadataStorage.js +27 -0
- package/metadata/types.d.ts +1 -1
- package/package.json +1 -1
- package/typings.d.ts +3 -0
- package/unit-of-work/ChangeSetComputer.js +20 -6
- package/unit-of-work/ChangeSetPersister.js +9 -7
- package/unit-of-work/IdentityMap.d.ts +3 -2
- package/unit-of-work/IdentityMap.js +30 -7
- package/unit-of-work/UnitOfWork.js +29 -3
- package/utils/EntityComparator.js +43 -15
- package/utils/QueryHelper.d.ts +6 -0
- package/utils/QueryHelper.js +51 -8
- package/utils/TransactionContext.d.ts +1 -0
- package/utils/TransactionContext.js +9 -3
- package/utils/TransactionManager.js +6 -2
- package/utils/Utils.js +1 -1
- package/utils/upsert-utils.d.ts +2 -1
- package/utils/upsert-utils.js +9 -5
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.2-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.2-dev.30';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|
package/utils/upsert-utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EntityData, EntityKey, EntityMetadata, FilterQuery } from '../typings.js';
|
|
2
2
|
import type { UpsertOptions } from '../drivers/IDatabaseDriver.js';
|
|
3
3
|
import { type Raw } from '../utils/RawQueryFragment.js';
|
|
4
|
+
import type { Platform } from '../platforms/Platform.js';
|
|
4
5
|
/** @internal */
|
|
5
6
|
export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | Raw, options: UpsertOptions<T>): (keyof T)[];
|
|
6
7
|
/**
|
|
@@ -12,7 +13,7 @@ export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefin
|
|
|
12
13
|
*/
|
|
13
14
|
export declare function getOnCreateGeneratedFields<T extends object>(meta: EntityMetadata<T>, data: T | EntityData<T>): EntityKey<T>[];
|
|
14
15
|
/** @internal */
|
|
15
|
-
export declare function getOnConflictReturningFields<T, P extends string>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | Raw, options: UpsertOptions<T, P
|
|
16
|
+
export declare function getOnConflictReturningFields<T, P extends string>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | Raw, options: UpsertOptions<T, P>, platform?: Platform): (keyof T)[] | '*';
|
|
16
17
|
/** @internal */
|
|
17
18
|
export declare function getWhereCondition<T extends object>(meta: EntityMetadata<T>, onConflictFields: (keyof T)[] | Raw | undefined, data: EntityData<T>, where: FilterQuery<T>): {
|
|
18
19
|
where: FilterQuery<T>;
|
package/utils/upsert-utils.js
CHANGED
|
@@ -89,11 +89,15 @@ export function getOnCreateGeneratedFields(meta, data) {
|
|
|
89
89
|
.map(prop => prop.name);
|
|
90
90
|
}
|
|
91
91
|
/** @internal */
|
|
92
|
-
export function getOnConflictReturningFields(meta, data, uniqueFields, options) {
|
|
92
|
+
export function getOnConflictReturningFields(meta, data, uniqueFields, options, platform) {
|
|
93
93
|
/* v8 ignore next */
|
|
94
94
|
if (!meta) {
|
|
95
95
|
return '*';
|
|
96
96
|
}
|
|
97
|
+
// props with explicit `returning` hint are reloaded even when supplied, as the database might normalize them
|
|
98
|
+
const returning = platform?.usesReturningStatement() || platform?.usesOutputStatement()
|
|
99
|
+
? meta.props.filter(p => p.returning).map(p => p.name)
|
|
100
|
+
: [];
|
|
97
101
|
const keys = meta.comparableProps
|
|
98
102
|
.filter(p => {
|
|
99
103
|
if (p.lazy || p.embeddable) {
|
|
@@ -112,17 +116,17 @@ export function getOnConflictReturningFields(meta, data, uniqueFields, options)
|
|
|
112
116
|
keys.push(meta.versionProperty);
|
|
113
117
|
}
|
|
114
118
|
if (options.onConflictAction === 'ignore') {
|
|
115
|
-
return keys;
|
|
119
|
+
return Utils.unique([...keys, ...returning]);
|
|
116
120
|
}
|
|
117
121
|
if (options.onConflictMergeFields) {
|
|
118
122
|
const onConflictMergeFields = expandFields(meta, options.onConflictMergeFields);
|
|
119
|
-
return keys.filter(key => !onConflictMergeFields.includes(key));
|
|
123
|
+
return Utils.unique([...keys.filter(key => !onConflictMergeFields.includes(key)), ...returning]);
|
|
120
124
|
}
|
|
121
125
|
if (options.onConflictExcludeFields) {
|
|
122
126
|
const onConflictExcludeFields = expandFields(meta, options.onConflictExcludeFields);
|
|
123
|
-
return [...
|
|
127
|
+
return Utils.unique([...keys, ...onConflictExcludeFields, ...returning]);
|
|
124
128
|
}
|
|
125
|
-
return keys.filter(key => !(key in data));
|
|
129
|
+
return Utils.unique([...keys.filter(key => !(key in data)), ...returning]);
|
|
126
130
|
}
|
|
127
131
|
function getPropertyValue(obj, key) {
|
|
128
132
|
if (!key.includes('.')) {
|