@mikro-orm/core 7.0.0-dev.266 → 7.0.0-dev.268
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/drivers/IDatabaseDriver.d.ts +6 -1
- package/entity/EntityFactory.js +1 -1
- package/index.d.ts +1 -1
- package/metadata/MetadataDiscovery.js +1 -1
- package/package.json +1 -1
- package/platforms/Platform.d.ts +3 -1
- package/platforms/Platform.js +1 -1
- package/typings.d.ts +4 -0
- package/unit-of-work/ChangeSetPersister.js +2 -2
- package/utils/Configuration.d.ts +3 -1
- package/utils/Utils.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes } from '../typings.js';
|
|
1
|
+
import type { ConnectionType, Constructor, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes } from '../typings.js';
|
|
2
2
|
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
|
|
3
3
|
import type { FlushMode, LockMode, QueryOrderMap, QueryFlag, LoadStrategy, PopulateHint, PopulatePath } from '../enums.js';
|
|
4
4
|
import type { Platform } from '../platforms/Platform.js';
|
|
@@ -7,6 +7,7 @@ import type { Collection } from '../entity/Collection.js';
|
|
|
7
7
|
import type { EntityManager } from '../EntityManager.js';
|
|
8
8
|
import type { DriverException } from '../exceptions.js';
|
|
9
9
|
import type { Configuration } from '../utils/Configuration.js';
|
|
10
|
+
import type { MikroORM } from '../MikroORM.js';
|
|
10
11
|
import type { LoggingOptions, LogContext } from '../logging/Logger.js';
|
|
11
12
|
import type { Raw } from '../utils/RawQueryFragment.js';
|
|
12
13
|
export declare const EntityManagerType: unique symbol;
|
|
@@ -65,6 +66,10 @@ export interface IDatabaseDriver<C extends Connection = Connection> {
|
|
|
65
66
|
schema?: string;
|
|
66
67
|
parentSchema?: string;
|
|
67
68
|
}): string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
getORMClass(): Constructor<MikroORM>;
|
|
68
73
|
}
|
|
69
74
|
export type EntityField<T, P extends string = PopulatePath.ALL> = keyof T | PopulatePath.ALL | AutoPath<T, P, `${PopulatePath.ALL}`>;
|
|
70
75
|
export type OrderDefinition<T> = (QueryOrderMap<T> & {
|
package/entity/EntityFactory.js
CHANGED
|
@@ -140,7 +140,7 @@ export class EntityFactory {
|
|
|
140
140
|
if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && Utils.isPlainObject(data[prop.name])) {
|
|
141
141
|
diff2[key] = entity[prop.name] ? helper(entity[prop.name]).getPrimaryKey(options.convertCustomTypes) : null;
|
|
142
142
|
}
|
|
143
|
-
if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE, ReferenceKind.SCALAR].includes(prop.kind) && prop.customType?.ensureComparable(meta, prop) && diff2[key] != null) {
|
|
143
|
+
if (!options.convertCustomTypes && [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE, ReferenceKind.SCALAR].includes(prop.kind) && prop.customType?.ensureComparable(meta, prop) && diff2[key] != null) {
|
|
144
144
|
const converted = prop.customType.convertToJSValue(diff2[key], this.platform, { force: true });
|
|
145
145
|
diff2[key] = prop.customType.convertToDatabaseValue(converted, this.platform, { fromQuery: true });
|
|
146
146
|
}
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module core
|
|
4
4
|
*/
|
|
5
5
|
export { EntityMetadata, PrimaryKeyProp, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config, EntityName } from './typings.js';
|
|
6
|
-
export type { CompiledFunctions, Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, InferEntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, EntityDTOFlat, EntityDTOProp, SerializeDTO, MigrationDiff, GenerateOptions, FilterObject, IMigrationRunner, IEntityGenerator, ISeedManager, IMigratorStorage, RequiredEntityData, CheckCallback, IndexCallback, FormulaCallback, FormulaTable, SchemaTable, SchemaColumns, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, MigrationInfo, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, EntityCtor, Subquery, PopulateHintOptions, Prefixes, } from './typings.js';
|
|
6
|
+
export type { CompiledFunctions, Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, InferEntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, EntityDTOFlat, EntityDTOProp, SerializeDTO, MigrationDiff, GenerateOptions, FilterObject, IMigrationRunner, IEntityGenerator, ISeedManager, SeederObject, IMigratorStorage, RequiredEntityData, CheckCallback, IndexCallback, FormulaCallback, FormulaTable, SchemaTable, SchemaColumns, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, MigrationInfo, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, EntityCtor, Subquery, PopulateHintOptions, Prefixes, } from './typings.js';
|
|
7
7
|
export * from './enums.js';
|
|
8
8
|
export * from './errors.js';
|
|
9
9
|
export * from './exceptions.js';
|
|
@@ -1474,7 +1474,7 @@ export class MetadataDiscovery {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
/* v8 ignore next */
|
|
1476
1476
|
if (prop.default != null) {
|
|
1477
|
-
return '' + this.platform.
|
|
1477
|
+
return '' + this.platform.convertVersionValue(prop.default, prop);
|
|
1478
1478
|
}
|
|
1479
1479
|
this.initCustomType(meta, prop, true);
|
|
1480
1480
|
const type = prop.customType?.runtimeType ?? prop.runtimeType ?? prop.type;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.268",
|
|
5
5
|
"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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
package/platforms/Platform.d.ts
CHANGED
|
@@ -66,7 +66,9 @@ export declare abstract class Platform {
|
|
|
66
66
|
$flags?: string;
|
|
67
67
|
};
|
|
68
68
|
isAllowedTopLevelOperator(operator: string): boolean;
|
|
69
|
-
|
|
69
|
+
convertVersionValue(value: Date | number, prop: EntityProperty): Date | string | number | {
|
|
70
|
+
$in: (string | number)[];
|
|
71
|
+
};
|
|
70
72
|
getDefaultVersionLength(): number;
|
|
71
73
|
allowsComparingTuples(): boolean;
|
|
72
74
|
isBigIntProperty(prop: EntityProperty): boolean;
|
package/platforms/Platform.js
CHANGED
package/typings.d.ts
CHANGED
|
@@ -1092,6 +1092,10 @@ export interface ISeedManager {
|
|
|
1092
1092
|
export interface Seeder<T extends Dictionary = Dictionary> {
|
|
1093
1093
|
run(em: EntityManager, context?: T): void | Promise<void>;
|
|
1094
1094
|
}
|
|
1095
|
+
export interface SeederObject {
|
|
1096
|
+
name: string;
|
|
1097
|
+
class: Constructor<Seeder>;
|
|
1098
|
+
}
|
|
1095
1099
|
export type ConnectionType = 'read' | 'write';
|
|
1096
1100
|
export type MetadataProcessor = (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>;
|
|
1097
1101
|
export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
@@ -272,7 +272,7 @@ export class ChangeSetPersister {
|
|
|
272
272
|
return this.driver.nativeUpdate(changeSet.meta.class, cond, changeSet.payload, options);
|
|
273
273
|
}
|
|
274
274
|
if (meta.versionProperty) {
|
|
275
|
-
cond[meta.versionProperty] = this.platform.
|
|
275
|
+
cond[meta.versionProperty] = this.platform.convertVersionValue(changeSet.entity[meta.versionProperty], meta.properties[meta.versionProperty]);
|
|
276
276
|
}
|
|
277
277
|
this.checkConcurrencyKeys(meta, changeSet, cond);
|
|
278
278
|
return this.driver.nativeUpdate(changeSet.meta.class, cond, changeSet.payload, options);
|
|
@@ -287,7 +287,7 @@ export class ChangeSetPersister {
|
|
|
287
287
|
const cond = Utils.getPrimaryKeyCond(cs.originalEntity, meta.primaryKeys.concat(...meta.concurrencyCheckKeys));
|
|
288
288
|
if (meta.versionProperty) {
|
|
289
289
|
// @ts-ignore
|
|
290
|
-
cond[meta.versionProperty] = this.platform.
|
|
290
|
+
cond[meta.versionProperty] = this.platform.convertVersionValue(cs.entity[meta.versionProperty], meta.properties[meta.versionProperty]);
|
|
291
291
|
}
|
|
292
292
|
return cond;
|
|
293
293
|
});
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NamingStrategy } from '../naming-strategy/NamingStrategy.js';
|
|
2
2
|
import { type CacheAdapter, type SyncCacheAdapter } from '../cache/CacheAdapter.js';
|
|
3
3
|
import type { EntityRepository } from '../entity/EntityRepository.js';
|
|
4
|
-
import type { AnyEntity, CompiledFunctions, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject } from '../typings.js';
|
|
4
|
+
import type { AnyEntity, CompiledFunctions, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject, Seeder, SeederObject } from '../typings.js';
|
|
5
5
|
import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
|
|
6
6
|
import { NullHighlighter } from '../utils/NullHighlighter.js';
|
|
7
7
|
import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
|
|
@@ -384,6 +384,8 @@ export interface SeederOptions {
|
|
|
384
384
|
* @default (className) => className
|
|
385
385
|
*/
|
|
386
386
|
fileName?: (className: string) => string;
|
|
387
|
+
/** List of seeder classes or objects to use instead of file-based discovery. */
|
|
388
|
+
seedersList?: (SeederObject | Constructor<Seeder>)[];
|
|
387
389
|
}
|
|
388
390
|
/**
|
|
389
391
|
* Connection pool configuration.
|
package/utils/Utils.js
CHANGED
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.268';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|