@mikro-orm/core 7.0.0-dev.230 → 7.0.0-dev.232
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/entity/EntityLoader.js +6 -4
- package/metadata/types.d.ts +51 -0
- package/package.json +1 -1
- package/typings.d.ts +11 -0
- package/utils/Utils.js +1 -1
package/entity/EntityLoader.js
CHANGED
|
@@ -578,16 +578,18 @@ export class EntityLoader {
|
|
|
578
578
|
}
|
|
579
579
|
return ret;
|
|
580
580
|
}, []);
|
|
581
|
-
if (ret.length === 0) {
|
|
582
|
-
return undefined;
|
|
583
|
-
}
|
|
584
581
|
// we need to automatically select the FKs too, e.g. for 1:m relations to be able to wire them with the items
|
|
585
582
|
if (prop.kind === ReferenceKind.ONE_TO_MANY || prop.kind === ReferenceKind.MANY_TO_MANY) {
|
|
586
583
|
const owner = prop.targetMeta.properties[prop.mappedBy];
|
|
587
|
-
|
|
584
|
+
// when the owning FK is lazy, we need to explicitly select it even without user-provided fields,
|
|
585
|
+
// otherwise the driver will exclude it and we won't be able to map children to their parent collections
|
|
586
|
+
if (owner && !ret.includes(owner.name) && (ret.length > 0 || owner.lazy)) {
|
|
588
587
|
ret.push(owner.name);
|
|
589
588
|
}
|
|
590
589
|
}
|
|
590
|
+
if (ret.length === 0) {
|
|
591
|
+
return undefined;
|
|
592
|
+
}
|
|
591
593
|
return ret;
|
|
592
594
|
}
|
|
593
595
|
getChildReferences(entities, prop, options, ref) {
|
package/metadata/types.d.ts
CHANGED
|
@@ -511,16 +511,67 @@ export interface SerializedPrimaryKeyOptions<T> extends PropertyOptions<T> {
|
|
|
511
511
|
}
|
|
512
512
|
type MaybeArray<T> = T | T[];
|
|
513
513
|
type Properties<T, H extends string> = MaybeArray<AutoPath<T, H>>;
|
|
514
|
+
/** Options for column within an index, supporting advanced index features like prefix length and collation. */
|
|
515
|
+
export interface IndexColumnOptions {
|
|
516
|
+
/** Column name or property path. */
|
|
517
|
+
name: string;
|
|
518
|
+
/** Sort order for the column (default: ASC). */
|
|
519
|
+
sort?: 'ASC' | 'DESC' | 'asc' | 'desc';
|
|
520
|
+
/** NULLS ordering for the column (PostgreSQL). */
|
|
521
|
+
nulls?: 'FIRST' | 'LAST' | 'first' | 'last';
|
|
522
|
+
/** Prefix length for the column (MySQL, MariaDB). */
|
|
523
|
+
length?: number;
|
|
524
|
+
/** Collation for the column (PostgreSQL, SQLite, or MySQL/MariaDB via expression). */
|
|
525
|
+
collation?: string;
|
|
526
|
+
}
|
|
514
527
|
interface BaseOptions<T, H extends string> {
|
|
515
528
|
name?: string;
|
|
516
529
|
properties?: (T extends EntityClass<infer P> ? Properties<P, H> : Properties<T, H>);
|
|
517
530
|
options?: Dictionary;
|
|
518
531
|
expression?: string | (T extends EntityClass<infer P> ? IndexCallback<P> : IndexCallback<T>);
|
|
532
|
+
/**
|
|
533
|
+
* Advanced column options for the index.
|
|
534
|
+
* When specified, allows fine-grained control over each column in the index including
|
|
535
|
+
* sort order, nulls ordering, prefix length, and collation.
|
|
536
|
+
* If both `columns` and `properties` are specified, `columns` takes precedence for index creation.
|
|
537
|
+
*/
|
|
538
|
+
columns?: IndexColumnOptions[];
|
|
539
|
+
/**
|
|
540
|
+
* Columns to include in the index but not as part of the key (PostgreSQL, MSSQL).
|
|
541
|
+
* These columns are stored in the leaf level of the index but not used for searching.
|
|
542
|
+
*/
|
|
543
|
+
include?: (T extends EntityClass<infer P> ? Properties<P, H> : Properties<T, H>);
|
|
544
|
+
/** Fill factor for the index as a percentage 0-100 (PostgreSQL, MSSQL). */
|
|
545
|
+
fillFactor?: number;
|
|
519
546
|
}
|
|
520
547
|
export interface UniqueOptions<T, H extends string = string> extends BaseOptions<T, H> {
|
|
521
548
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
549
|
+
/**
|
|
550
|
+
* Whether the index is disabled (MSSQL only).
|
|
551
|
+
* A disabled index is not used for query planning and is not maintained on writes.
|
|
552
|
+
* It can be re-enabled later using `ALTER INDEX ... REBUILD`.
|
|
553
|
+
*/
|
|
554
|
+
disabled?: boolean;
|
|
522
555
|
}
|
|
523
556
|
export interface IndexOptions<T, H extends string = string> extends BaseOptions<T, H> {
|
|
524
557
|
type?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Whether the index is invisible/hidden from the query optimizer (MySQL 8+, MariaDB 10.6+, MongoDB).
|
|
560
|
+
* An invisible index is still maintained on writes but not used for query planning.
|
|
561
|
+
* Useful for testing the impact of removing an index before actually dropping it.
|
|
562
|
+
*/
|
|
563
|
+
invisible?: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* Whether the index is disabled (MSSQL only).
|
|
566
|
+
* A disabled index is not used for query planning and is not maintained on writes.
|
|
567
|
+
* It can be re-enabled later using `ALTER INDEX ... REBUILD`.
|
|
568
|
+
*/
|
|
569
|
+
disabled?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Whether the index should be clustered (MariaDB, MSSQL).
|
|
572
|
+
* A clustered index determines the physical order of data in the table.
|
|
573
|
+
* Only one clustered index can exist per table.
|
|
574
|
+
*/
|
|
575
|
+
clustered?: boolean;
|
|
525
576
|
}
|
|
526
577
|
export {};
|
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.232",
|
|
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/typings.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { SerializationContext } from './serialization/SerializationContext.
|
|
|
11
11
|
import type { SerializeOptions } from './serialization/EntitySerializer.js';
|
|
12
12
|
import type { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
13
13
|
import type { EntitySchema } from './metadata/EntitySchema.js';
|
|
14
|
+
import type { IndexColumnOptions } from './metadata/types.js';
|
|
14
15
|
import type { Type, types } from './types/index.js';
|
|
15
16
|
import type { Platform } from './platforms/Platform.js';
|
|
16
17
|
import type { Configuration } from './utils/Configuration.js';
|
|
@@ -637,6 +638,12 @@ export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> =
|
|
|
637
638
|
type?: string;
|
|
638
639
|
options?: Dictionary;
|
|
639
640
|
expression?: string | IndexCallback<Entity>;
|
|
641
|
+
columns?: IndexColumnOptions[];
|
|
642
|
+
include?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
643
|
+
fillFactor?: number;
|
|
644
|
+
invisible?: boolean;
|
|
645
|
+
disabled?: boolean;
|
|
646
|
+
clustered?: boolean;
|
|
640
647
|
}[];
|
|
641
648
|
uniques: {
|
|
642
649
|
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
@@ -644,6 +651,10 @@ export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> =
|
|
|
644
651
|
options?: Dictionary;
|
|
645
652
|
expression?: string | IndexCallback<Entity>;
|
|
646
653
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
654
|
+
columns?: IndexColumnOptions[];
|
|
655
|
+
include?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
656
|
+
fillFactor?: number;
|
|
657
|
+
disabled?: boolean;
|
|
647
658
|
}[];
|
|
648
659
|
checks: CheckConstraint<Entity>[];
|
|
649
660
|
repositoryClass?: string;
|
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.232';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|