@mikro-orm/core 6.2.10-dev.9 → 6.2.10-dev.91
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 +1 -2
- package/EntityManager.js +26 -24
- package/decorators/Check.js +1 -2
- package/decorators/CreateRequestContext.js +2 -3
- package/decorators/Embeddable.js +1 -2
- package/decorators/Embedded.js +1 -2
- package/decorators/Entity.js +1 -2
- package/decorators/Enum.js +1 -2
- package/decorators/Filter.js +1 -2
- package/decorators/Formula.js +1 -2
- package/decorators/Indexed.d.ts +3 -3
- package/decorators/Indexed.js +2 -3
- package/decorators/ManyToMany.js +1 -2
- package/decorators/ManyToOne.js +1 -2
- package/decorators/OneToMany.js +2 -3
- package/decorators/OneToOne.d.ts +1 -1
- package/decorators/OneToOne.js +1 -2
- package/decorators/PrimaryKey.d.ts +3 -2
- package/decorators/PrimaryKey.js +2 -3
- package/decorators/Property.d.ts +1 -1
- package/decorators/Property.js +1 -2
- package/decorators/hooks.js +10 -11
- package/drivers/DatabaseDriver.js +1 -1
- package/drivers/IDatabaseDriver.d.ts +2 -1
- package/entity/ArrayCollection.d.ts +0 -1
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityLoader.js +3 -0
- package/entity/Reference.d.ts +0 -1
- package/entity/Reference.js +10 -7
- package/entity/WrappedEntity.d.ts +0 -1
- package/entity/wrap.js +2 -3
- package/events/TransactionEventBroadcaster.d.ts +2 -2
- package/index.d.ts +1 -1
- package/index.mjs +1 -0
- package/metadata/MetadataDiscovery.js +6 -4
- package/naming-strategy/AbstractNamingStrategy.d.ts +13 -0
- package/naming-strategy/AbstractNamingStrategy.js +25 -0
- package/naming-strategy/NamingStrategy.d.ts +27 -1
- package/package.json +2 -2
- package/platforms/Platform.d.ts +6 -2
- package/platforms/Platform.js +17 -5
- package/serialization/EntitySerializer.js +2 -2
- package/serialization/SerializationContext.d.ts +2 -2
- package/types/BigIntType.d.ts +2 -2
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/CharacterType.d.ts +7 -0
- package/types/CharacterType.js +13 -0
- package/types/DateTimeType.d.ts +1 -0
- package/types/DateTimeType.js +3 -0
- package/types/DateType.d.ts +1 -0
- package/types/DateType.js +3 -0
- package/types/DecimalType.d.ts +2 -2
- package/types/IntervalType.d.ts +1 -0
- package/types/IntervalType.js +3 -0
- package/types/JsonType.js +1 -1
- package/types/StringType.d.ts +1 -0
- package/types/StringType.js +3 -0
- package/types/TimeType.d.ts +1 -0
- package/types/TimeType.js +3 -0
- package/types/Type.d.ts +16 -2
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/index.d.ts +19 -16
- package/types/index.js +34 -31
- package/typings.d.ts +24 -19
- package/unit-of-work/ChangeSet.d.ts +0 -1
- package/unit-of-work/ChangeSetPersister.d.ts +1 -1
- package/unit-of-work/ChangeSetPersister.js +5 -3
- package/unit-of-work/UnitOfWork.d.ts +1 -1
- package/unit-of-work/UnitOfWork.js +32 -18
- package/utils/Configuration.js +2 -2
- package/utils/ConfigurationLoader.js +1 -0
- package/utils/Cursor.d.ts +0 -1
- package/utils/DataloaderUtils.d.ts +3 -3
- package/utils/DataloaderUtils.js +4 -4
- package/utils/EntityComparator.d.ts +13 -0
- package/utils/EntityComparator.js +62 -34
- package/utils/RawQueryFragment.d.ts +1 -2
- package/utils/RawQueryFragment.js +4 -4
- package/utils/Utils.d.ts +4 -6
- package/utils/Utils.js +13 -10
- package/utils/clone.js +1 -2
- package/utils/upsert-utils.d.ts +3 -2
- package/utils/upsert-utils.js +4 -5
package/index.mjs
CHANGED
|
@@ -25,6 +25,7 @@ export const ChangeSet = mod.ChangeSet;
|
|
|
25
25
|
export const ChangeSetComputer = mod.ChangeSetComputer;
|
|
26
26
|
export const ChangeSetPersister = mod.ChangeSetPersister;
|
|
27
27
|
export const ChangeSetType = mod.ChangeSetType;
|
|
28
|
+
export const CharacterType = mod.CharacterType;
|
|
28
29
|
export const Check = mod.Check;
|
|
29
30
|
export const CheckConstraintViolationException = mod.CheckConstraintViolationException;
|
|
30
31
|
export const Collection = mod.Collection;
|
|
@@ -109,7 +109,7 @@ class MetadataDiscovery {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
filtered.forEach(meta => Object.values(meta.properties).forEach(prop => this.initIndexes(prop)));
|
|
112
|
+
filtered.forEach(meta => Object.values(meta.properties).forEach(prop => this.initIndexes(meta, prop)));
|
|
113
113
|
filtered.forEach(meta => this.autoWireBidirectionalProperties(meta));
|
|
114
114
|
filtered.forEach(meta => this.findReferencingProperties(meta, filtered));
|
|
115
115
|
for (const meta of filtered) {
|
|
@@ -1147,7 +1147,8 @@ class MetadataDiscovery {
|
|
|
1147
1147
|
&& !SCALAR_TYPES.includes(prop.type)
|
|
1148
1148
|
// or it might be inferred via ts-morph to some generic type alias
|
|
1149
1149
|
&& !prop.type.match(/[<>:"';{}]/)) {
|
|
1150
|
-
prop.
|
|
1150
|
+
const type = prop.length != null && !prop.type.endsWith(`(${prop.length})`) ? `${prop.type}(${prop.length})` : prop.type;
|
|
1151
|
+
prop.columnTypes = [type];
|
|
1151
1152
|
}
|
|
1152
1153
|
else {
|
|
1153
1154
|
prop.columnTypes = [mappedType.getColumnType(prop, this.platform)];
|
|
@@ -1204,8 +1205,9 @@ class MetadataDiscovery {
|
|
|
1204
1205
|
}
|
|
1205
1206
|
prop.unsigned ??= (prop.primary || prop.unsigned) && this.isNumericProperty(prop) && this.platform.supportsUnsigned();
|
|
1206
1207
|
}
|
|
1207
|
-
initIndexes(prop) {
|
|
1208
|
-
|
|
1208
|
+
initIndexes(meta, prop) {
|
|
1209
|
+
const hasIndex = meta.indexes.some(idx => idx.properties?.length === 1 && idx.properties[0] === prop.name);
|
|
1210
|
+
if (prop.kind === enums_1.ReferenceKind.MANY_TO_ONE && this.platform.indexForeignKeys() && !hasIndex) {
|
|
1209
1211
|
prop.index ??= true;
|
|
1210
1212
|
}
|
|
1211
1213
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NamingStrategy } from './NamingStrategy';
|
|
2
|
+
import { type ReferenceKind } from '../enums';
|
|
2
3
|
export declare abstract class AbstractNamingStrategy implements NamingStrategy {
|
|
3
4
|
getClassName(file: string, separator?: string): string;
|
|
4
5
|
classToMigrationName(timestamp: string, customMigrationName?: string): string;
|
|
@@ -8,7 +9,19 @@ export declare abstract class AbstractNamingStrategy implements NamingStrategy {
|
|
|
8
9
|
*/
|
|
9
10
|
getEntityName(tableName: string, schemaName?: string): string;
|
|
10
11
|
columnNameToProperty(columnName: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* @inheritDoc
|
|
14
|
+
*/
|
|
15
|
+
getEnumClassName(columnName: string, tableName: string, schemaName?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
enumValueToEnumProperty(enumValue: string, columnName: string, tableName: string, schemaName?: string): string;
|
|
11
20
|
aliasName(entityName: string, index: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
inverseSideName(entityName: string, propertyName: string, kind: ReferenceKind): string;
|
|
12
25
|
abstract classToTableName(entityName: string): string;
|
|
13
26
|
abstract joinColumnName(propertyName: string): string;
|
|
14
27
|
abstract joinKeyColumnName(entityName: string, referencedColumnName?: string): string;
|
|
@@ -47,9 +47,34 @@ class AbstractNamingStrategy {
|
|
|
47
47
|
}
|
|
48
48
|
return propName;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
53
|
+
getEnumClassName(columnName, tableName, schemaName) {
|
|
54
|
+
return this.getEntityName(`${tableName}_${columnName}`, schemaName);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
enumValueToEnumProperty(enumValue, columnName, tableName, schemaName) {
|
|
60
|
+
return enumValue.toUpperCase();
|
|
61
|
+
}
|
|
50
62
|
aliasName(entityName, index) {
|
|
51
63
|
// Take only the first letter of the prefix to keep character counts down since some engines have character limits
|
|
52
64
|
return entityName.charAt(0).toLowerCase() + index;
|
|
53
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
69
|
+
inverseSideName(entityName, propertyName, kind) {
|
|
70
|
+
if (kind === 'm:n') {
|
|
71
|
+
return propertyName + 'Inverse';
|
|
72
|
+
}
|
|
73
|
+
const suffix = kind === '1:m' && !entityName.endsWith('Collection') ? 'Collection' : '';
|
|
74
|
+
if (entityName.length === 1) {
|
|
75
|
+
return entityName[0].toLowerCase() + suffix;
|
|
76
|
+
}
|
|
77
|
+
return entityName[0].toLowerCase() + entityName.substring(1) + suffix;
|
|
78
|
+
}
|
|
54
79
|
}
|
|
55
80
|
exports.AbstractNamingStrategy = AbstractNamingStrategy;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReferenceKind } from '../enums';
|
|
1
2
|
export interface NamingStrategy {
|
|
2
3
|
/**
|
|
3
4
|
* Return a name of the class based on its file name
|
|
@@ -15,6 +16,27 @@ export interface NamingStrategy {
|
|
|
15
16
|
* Return a column name for a property
|
|
16
17
|
*/
|
|
17
18
|
propertyToColumnName(propertyName: string, object?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get an enum class name.
|
|
21
|
+
*
|
|
22
|
+
* @param columnName The column name which has the enum.
|
|
23
|
+
* @param tableName The table name of the column.
|
|
24
|
+
* @param schemaName The schema name of the column.
|
|
25
|
+
*
|
|
26
|
+
* @return A new class name that will be used for the enum.
|
|
27
|
+
*/
|
|
28
|
+
getEnumClassName(columnName: string, tableName: string, schemaName?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get an enum option name for a given enum value.
|
|
31
|
+
*
|
|
32
|
+
* @param enumValue The enum value to generate a name for.
|
|
33
|
+
* @param columnName The column name which has the enum.
|
|
34
|
+
* @param tableName The table name of the column.
|
|
35
|
+
* @param schemaName The schema name of the column.
|
|
36
|
+
*
|
|
37
|
+
* @return The name of the enum property that will hold the value.
|
|
38
|
+
*/
|
|
39
|
+
enumValueToEnumProperty(enumValue: string, columnName: string, tableName: string, schemaName?: string): string;
|
|
18
40
|
/**
|
|
19
41
|
* Return a name of the entity class based on database table name (used in `EntityGenerator`).
|
|
20
42
|
* Default implementation ignores the schema name.
|
|
@@ -41,7 +63,7 @@ export interface NamingStrategy {
|
|
|
41
63
|
*/
|
|
42
64
|
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean): string;
|
|
43
65
|
/**
|
|
44
|
-
* Returns key/constraint name for given type. Some drivers might not support all the types (e.g. mysql and sqlite enforce the PK name).
|
|
66
|
+
* Returns key/constraint name for the given type. Some drivers might not support all the types (e.g. mysql and sqlite enforce the PK name).
|
|
45
67
|
*/
|
|
46
68
|
indexName(tableName: string, columns: string[], type: 'primary' | 'foreign' | 'unique' | 'index' | 'sequence' | 'check'): string;
|
|
47
69
|
/**
|
|
@@ -49,4 +71,8 @@ export interface NamingStrategy {
|
|
|
49
71
|
* ensured via appended index parameter. It is optional to use it as long as you ensure it will be unique.
|
|
50
72
|
*/
|
|
51
73
|
aliasName(entityName: string, index: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the name of the inverse side property. Used in the `EntityGenerator` with `bidirectionalRelations` option.
|
|
76
|
+
*/
|
|
77
|
+
inverseSideName(entityName: string, propertyName: string, kind: ReferenceKind): string;
|
|
52
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.2.10-dev.
|
|
3
|
+
"version": "6.2.10-dev.91",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.2.10-dev.
|
|
67
|
+
"mikro-orm": "6.2.10-dev.91",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/platforms/Platform.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare abstract class Platform {
|
|
|
58
58
|
length?: number;
|
|
59
59
|
}): string;
|
|
60
60
|
getDefaultDateTimeLength(): number;
|
|
61
|
+
getDefaultVarcharLength(): number;
|
|
62
|
+
getDefaultCharLength(): number;
|
|
61
63
|
getDateTypeDeclarationSQL(length?: number): string;
|
|
62
64
|
getTimeTypeDeclarationSQL(length?: number): string;
|
|
63
65
|
getRegExpOperator(val?: unknown, flags?: string): string;
|
|
@@ -69,7 +71,6 @@ export declare abstract class Platform {
|
|
|
69
71
|
quoteVersionValue(value: Date | number, prop: EntityProperty): Date | string | number;
|
|
70
72
|
getDefaultVersionLength(): number;
|
|
71
73
|
allowsComparingTuples(): boolean;
|
|
72
|
-
allowsUniqueBatchUpdates(): boolean;
|
|
73
74
|
isBigIntProperty(prop: EntityProperty): boolean;
|
|
74
75
|
isRaw(value: any): boolean;
|
|
75
76
|
getDefaultSchemaName(): string | undefined;
|
|
@@ -99,6 +100,9 @@ export declare abstract class Platform {
|
|
|
99
100
|
unsigned?: boolean;
|
|
100
101
|
autoincrement?: boolean;
|
|
101
102
|
}): string;
|
|
103
|
+
getCharTypeDeclarationSQL(column: {
|
|
104
|
+
length?: number;
|
|
105
|
+
}): string;
|
|
102
106
|
getVarcharTypeDeclarationSQL(column: {
|
|
103
107
|
length?: number;
|
|
104
108
|
}): string;
|
|
@@ -144,7 +148,7 @@ export declare abstract class Platform {
|
|
|
144
148
|
getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
|
|
145
149
|
convertsJsonAutomatically(): boolean;
|
|
146
150
|
convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
|
|
147
|
-
convertJsonToJSValue(value: unknown): unknown;
|
|
151
|
+
convertJsonToJSValue(value: unknown, prop: EntityProperty): unknown;
|
|
148
152
|
convertDateToJSValue(value: string | Date): string;
|
|
149
153
|
convertIntervalToJSValue(value: string): unknown;
|
|
150
154
|
convertIntervalToDatabaseValue(value: unknown): unknown;
|
package/platforms/Platform.js
CHANGED
|
@@ -96,6 +96,12 @@ class Platform {
|
|
|
96
96
|
getDefaultDateTimeLength() {
|
|
97
97
|
return 0;
|
|
98
98
|
}
|
|
99
|
+
getDefaultVarcharLength() {
|
|
100
|
+
return 255;
|
|
101
|
+
}
|
|
102
|
+
getDefaultCharLength() {
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
99
105
|
getDateTypeDeclarationSQL(length) {
|
|
100
106
|
return 'date' + (length ? `(${length})` : '');
|
|
101
107
|
}
|
|
@@ -123,9 +129,6 @@ class Platform {
|
|
|
123
129
|
allowsComparingTuples() {
|
|
124
130
|
return true;
|
|
125
131
|
}
|
|
126
|
-
allowsUniqueBatchUpdates() {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
132
|
isBigIntProperty(prop) {
|
|
130
133
|
return prop.columnTypes && prop.columnTypes[0] === 'bigint';
|
|
131
134
|
}
|
|
@@ -153,8 +156,11 @@ class Platform {
|
|
|
153
156
|
getBigIntTypeDeclarationSQL(column) {
|
|
154
157
|
return 'bigint';
|
|
155
158
|
}
|
|
159
|
+
getCharTypeDeclarationSQL(column) {
|
|
160
|
+
return `char(${column.length ?? this.getDefaultCharLength()})`;
|
|
161
|
+
}
|
|
156
162
|
getVarcharTypeDeclarationSQL(column) {
|
|
157
|
-
return `varchar(${column.length ??
|
|
163
|
+
return `varchar(${column.length ?? this.getDefaultVarcharLength()})`;
|
|
158
164
|
}
|
|
159
165
|
getIntervalTypeDeclarationSQL(column) {
|
|
160
166
|
return 'interval' + (column.length ? `(${column.length})` : '');
|
|
@@ -195,6 +201,8 @@ class Platform {
|
|
|
195
201
|
return types_1.Type.getType(types_1.ArrayType);
|
|
196
202
|
}
|
|
197
203
|
switch (this.extractSimpleType(type)) {
|
|
204
|
+
case 'character':
|
|
205
|
+
case 'char': return types_1.Type.getType(types_1.CharacterType);
|
|
198
206
|
case 'string':
|
|
199
207
|
case 'varchar': return types_1.Type.getType(types_1.StringType);
|
|
200
208
|
case 'interval': return types_1.Type.getType(types_1.IntervalType);
|
|
@@ -274,7 +282,11 @@ class Platform {
|
|
|
274
282
|
convertJsonToDatabaseValue(value, context) {
|
|
275
283
|
return JSON.stringify(value);
|
|
276
284
|
}
|
|
277
|
-
convertJsonToJSValue(value) {
|
|
285
|
+
convertJsonToJSValue(value, prop) {
|
|
286
|
+
const isObjectEmbedded = prop.embedded && prop.object;
|
|
287
|
+
if ((this.convertsJsonAutomatically() || isObjectEmbedded) && ['json', 'jsonb', this.getJsonDeclarationSQL()].includes(prop.columnTypes[0])) {
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
278
290
|
return (0, Utils_1.parseJsonSafe)(value);
|
|
279
291
|
}
|
|
280
292
|
convertDateToJSValue(value) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.EntitySerializer = void 0;
|
|
4
|
+
exports.serialize = serialize;
|
|
4
5
|
const wrap_1 = require("../entity/wrap");
|
|
5
6
|
const Utils_1 = require("../utils/Utils");
|
|
6
7
|
const enums_1 = require("../enums");
|
|
@@ -210,4 +211,3 @@ function serialize(entities, options) {
|
|
|
210
211
|
}
|
|
211
212
|
return EntitySerializer.serialize(entities, options);
|
|
212
213
|
}
|
|
213
|
-
exports.serialize = serialize;
|
|
@@ -5,7 +5,7 @@ import type { Configuration } from '../utils/Configuration';
|
|
|
5
5
|
* Before we process a property, we call `visit` that checks if it is not a cycle path (but allows to pass cycles that
|
|
6
6
|
* are defined in populate hint). If not, we proceed and call `leave` afterwards.
|
|
7
7
|
*/
|
|
8
|
-
export declare class SerializationContext<T> {
|
|
8
|
+
export declare class SerializationContext<T extends object> {
|
|
9
9
|
private readonly config;
|
|
10
10
|
private readonly populate;
|
|
11
11
|
private readonly fields?;
|
|
@@ -23,7 +23,7 @@ export declare class SerializationContext<T> {
|
|
|
23
23
|
/**
|
|
24
24
|
* When initializing new context, we need to propagate it to the whole entity graph recursively.
|
|
25
25
|
*/
|
|
26
|
-
static propagate(root: SerializationContext<
|
|
26
|
+
static propagate(root: SerializationContext<any>, entity: AnyEntity, isVisible: (meta: EntityMetadata, prop: string) => boolean): void;
|
|
27
27
|
isMarkedAsPopulated(entityName: string, prop: string): boolean;
|
|
28
28
|
isPartiallyLoaded(entityName: string, prop: string): boolean;
|
|
29
29
|
private register;
|
package/types/BigIntType.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import type { EntityProperty } from '../typings';
|
|
|
6
6
|
* or numbers (safe only for values up to `Number.MAX_SAFE_INTEGER`), or strings, depending on the `mode`.
|
|
7
7
|
*/
|
|
8
8
|
export declare class BigIntType extends Type<string | bigint | number | null | undefined, string | null | undefined> {
|
|
9
|
-
mode?: "
|
|
10
|
-
constructor(mode?: "
|
|
9
|
+
mode?: ("bigint" | "number" | "string") | undefined;
|
|
10
|
+
constructor(mode?: ("bigint" | "number" | "string") | undefined);
|
|
11
11
|
convertToDatabaseValue(value: string | bigint | null | undefined): string | null | undefined;
|
|
12
12
|
convertToJSValue(value: string | bigint | null | undefined): bigint | number | string | null | undefined;
|
|
13
13
|
toJSON(value: string | bigint | null | undefined): string | bigint | null | undefined;
|
package/types/BigIntType.js
CHANGED
package/types/BlobType.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StringType } from './StringType';
|
|
2
|
+
import type { Platform } from '../platforms';
|
|
3
|
+
import type { EntityProperty } from '../typings';
|
|
4
|
+
export declare class CharacterType extends StringType {
|
|
5
|
+
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
6
|
+
getDefaultLength(platform: Platform): number;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CharacterType = void 0;
|
|
4
|
+
const StringType_1 = require("./StringType");
|
|
5
|
+
class CharacterType extends StringType_1.StringType {
|
|
6
|
+
getColumnType(prop, platform) {
|
|
7
|
+
return platform.getCharTypeDeclarationSQL(prop);
|
|
8
|
+
}
|
|
9
|
+
getDefaultLength(platform) {
|
|
10
|
+
return platform.getDefaultCharLength();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.CharacterType = CharacterType;
|
package/types/DateTimeType.d.ts
CHANGED
package/types/DateTimeType.js
CHANGED
package/types/DateType.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export declare class DateType extends Type<string | null | undefined, string | n
|
|
|
6
6
|
ensureComparable(): boolean;
|
|
7
7
|
convertToJSValue(value: any, platform: Platform): string | null | undefined;
|
|
8
8
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
9
|
+
getDefaultLength(platform: Platform): number;
|
|
9
10
|
}
|
package/types/DateType.js
CHANGED
package/types/DecimalType.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type { EntityProperty } from '../typings';
|
|
|
5
5
|
* Type that maps an SQL DECIMAL to a JS string or number.
|
|
6
6
|
*/
|
|
7
7
|
export declare class DecimalType extends Type<string | number, string> {
|
|
8
|
-
mode?: "
|
|
9
|
-
constructor(mode?: "
|
|
8
|
+
mode?: ("number" | "string") | undefined;
|
|
9
|
+
constructor(mode?: ("number" | "string") | undefined);
|
|
10
10
|
convertToJSValue(value: string): number | string;
|
|
11
11
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
12
12
|
compareAsType(): string;
|
package/types/IntervalType.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export declare class IntervalType extends Type<string | null | undefined, string
|
|
|
5
5
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
6
6
|
convertToJSValue(value: string | null | undefined, platform: Platform): string | null | undefined;
|
|
7
7
|
convertToDatabaseValue(value: string | null | undefined, platform: Platform): string | null | undefined;
|
|
8
|
+
getDefaultLength(platform: Platform): number;
|
|
8
9
|
}
|
package/types/IntervalType.js
CHANGED
|
@@ -12,5 +12,8 @@ class IntervalType extends Type_1.Type {
|
|
|
12
12
|
convertToDatabaseValue(value, platform) {
|
|
13
13
|
return platform.convertIntervalToDatabaseValue(value);
|
|
14
14
|
}
|
|
15
|
+
getDefaultLength(platform) {
|
|
16
|
+
return platform.getDefaultDateTimeLength();
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
exports.IntervalType = IntervalType;
|
package/types/JsonType.js
CHANGED
|
@@ -16,7 +16,7 @@ class JsonType extends Type_1.Type {
|
|
|
16
16
|
return key + platform.castColumn(this.prop);
|
|
17
17
|
}
|
|
18
18
|
convertToJSValue(value, platform) {
|
|
19
|
-
return platform.convertJsonToJSValue(value);
|
|
19
|
+
return platform.convertJsonToJSValue(value, this.prop);
|
|
20
20
|
}
|
|
21
21
|
getColumnType(prop, platform) {
|
|
22
22
|
return platform.getJsonDeclarationSQL();
|
package/types/StringType.d.ts
CHANGED
package/types/StringType.js
CHANGED
package/types/TimeType.d.ts
CHANGED
package/types/TimeType.js
CHANGED
package/types/Type.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { inspect } from 'util';
|
|
3
2
|
import type { Platform } from '../platforms';
|
|
4
3
|
import type { Constructor, EntityMetadata, EntityProperty } from '../typings';
|
|
@@ -59,7 +58,22 @@ export declare abstract class Type<JSType = string, DBType = JSType> {
|
|
|
59
58
|
* Gets the SQL declaration snippet for a field of this type.
|
|
60
59
|
*/
|
|
61
60
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
62
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Get the default length for values of this type
|
|
63
|
+
*
|
|
64
|
+
* When doing schema generation, if neither "length" nor "columnType" option is provided,
|
|
65
|
+
* the length will be defaulted to this value.
|
|
66
|
+
*
|
|
67
|
+
* When doing entity generation, if the type is recognized to this type, and the inferred length is this value,
|
|
68
|
+
* the length option will be omitted in the output. If this method is not defined, length is always outputted
|
|
69
|
+
* based on what is in the database metadata.
|
|
70
|
+
*
|
|
71
|
+
* @param platform The platform the default will be used for.
|
|
72
|
+
*
|
|
73
|
+
* @return The default value for the given platform.
|
|
74
|
+
*/
|
|
75
|
+
getDefaultLength?(platform: Platform): number;
|
|
76
|
+
static getType<JSType, DBType = JSType, TypeClass extends Constructor<Type<JSType, DBType>> = Constructor<Type<JSType, DBType>>>(cls: TypeClass): InstanceType<TypeClass>;
|
|
63
77
|
/**
|
|
64
78
|
* Checks whether the argument is instance of `Type`.
|
|
65
79
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DateType } from './DateType';
|
|
3
|
-
import { TimeType } from './TimeType';
|
|
4
|
-
import { DateTimeType } from './DateTimeType';
|
|
1
|
+
import { ArrayType } from './ArrayType';
|
|
5
2
|
import { BigIntType } from './BigIntType';
|
|
6
3
|
import { BlobType } from './BlobType';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { BooleanType } from './BooleanType';
|
|
5
|
+
import { DateTimeType } from './DateTimeType';
|
|
6
|
+
import { DateType } from './DateType';
|
|
7
|
+
import { DecimalType } from './DecimalType';
|
|
8
|
+
import { DoubleType } from './DoubleType';
|
|
9
9
|
import { EnumArrayType } from './EnumArrayType';
|
|
10
10
|
import { EnumType } from './EnumType';
|
|
11
|
-
import {
|
|
11
|
+
import { CharacterType } from './CharacterType';
|
|
12
|
+
import { FloatType } from './FloatType';
|
|
12
13
|
import { IntegerType } from './IntegerType';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
14
|
+
import { IntervalType } from './IntervalType';
|
|
15
|
+
import { JsonType } from './JsonType';
|
|
15
16
|
import { MediumIntType } from './MediumIntType';
|
|
16
|
-
import {
|
|
17
|
-
import { DoubleType } from './DoubleType';
|
|
18
|
-
import { BooleanType } from './BooleanType';
|
|
19
|
-
import { DecimalType } from './DecimalType';
|
|
17
|
+
import { SmallIntType } from './SmallIntType';
|
|
20
18
|
import { StringType } from './StringType';
|
|
21
|
-
import { UuidType } from './UuidType';
|
|
22
19
|
import { TextType } from './TextType';
|
|
23
|
-
import {
|
|
20
|
+
import { TimeType } from './TimeType';
|
|
21
|
+
import { TinyIntType } from './TinyIntType';
|
|
22
|
+
import { IType, TransformContext, Type } from './Type';
|
|
23
|
+
import { Uint8ArrayType } from './Uint8ArrayType';
|
|
24
24
|
import { UnknownType } from './UnknownType';
|
|
25
|
-
|
|
25
|
+
import { UuidType } from './UuidType';
|
|
26
|
+
export { Type, DateType, TimeType, DateTimeType, BigIntType, BlobType, Uint8ArrayType, ArrayType, EnumArrayType, EnumType, JsonType, IntegerType, SmallIntType, TinyIntType, MediumIntType, FloatType, DoubleType, BooleanType, DecimalType, StringType, UuidType, TextType, UnknownType, TransformContext, IntervalType, IType, CharacterType, };
|
|
26
27
|
export declare const types: {
|
|
27
28
|
readonly date: typeof DateType;
|
|
28
29
|
readonly time: typeof TimeType;
|
|
@@ -42,6 +43,7 @@ export declare const types: {
|
|
|
42
43
|
readonly double: typeof DoubleType;
|
|
43
44
|
readonly boolean: typeof BooleanType;
|
|
44
45
|
readonly decimal: typeof DecimalType;
|
|
46
|
+
readonly character: typeof CharacterType;
|
|
45
47
|
readonly string: typeof StringType;
|
|
46
48
|
readonly uuid: typeof UuidType;
|
|
47
49
|
readonly text: typeof TextType;
|
|
@@ -67,6 +69,7 @@ export declare const t: {
|
|
|
67
69
|
readonly double: typeof DoubleType;
|
|
68
70
|
readonly boolean: typeof BooleanType;
|
|
69
71
|
readonly decimal: typeof DecimalType;
|
|
72
|
+
readonly character: typeof CharacterType;
|
|
70
73
|
readonly string: typeof StringType;
|
|
71
74
|
readonly uuid: typeof UuidType;
|
|
72
75
|
readonly text: typeof TextType;
|