@mikro-orm/core 7.3.0-dev.16 → 7.3.0-dev.17
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/defineEntity.d.ts +2 -1
- package/entity/defineEntity.js +1 -0
- package/package.json +1 -1
- package/types/DoubleType.d.ts +7 -3
- package/types/DoubleType.js +8 -3
- package/utils/Utils.js +1 -1
package/entity/defineEntity.d.ts
CHANGED
|
@@ -600,7 +600,7 @@ type EntityTarget = {
|
|
|
600
600
|
'~entity': any;
|
|
601
601
|
} | EntityClass;
|
|
602
602
|
declare const propertyBuilders: PropertyBuilders;
|
|
603
|
-
type PropertyBuildersOverrideKeys = 'bigint' | 'array' | 'decimal' | 'json' | 'string' | 'text' | 'datetime' | 'time' | 'enum';
|
|
603
|
+
type PropertyBuildersOverrideKeys = 'bigint' | 'array' | 'decimal' | 'double' | 'json' | 'string' | 'text' | 'datetime' | 'time' | 'enum';
|
|
604
604
|
/** Map of factory functions for creating type-safe property builders (scalars, enums, embeddables, and relations). */
|
|
605
605
|
export type PropertyBuilders = {
|
|
606
606
|
[K in Exclude<keyof typeof types, PropertyBuildersOverrideKeys>]: () => UniversalPropertyOptionsBuilder<InferPropertyValueType<(typeof types)[K]>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -608,6 +608,7 @@ export type PropertyBuilders = {
|
|
|
608
608
|
bigint: <Mode extends 'bigint' | 'number' | 'string' = 'bigint'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.bigint<Mode>>, EmptyOptions, IncludeKeysForProperty>;
|
|
609
609
|
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.array<T>>, EmptyOptions, IncludeKeysForProperty>;
|
|
610
610
|
decimal: <Mode extends 'number' | 'string' = 'string'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.decimal<Mode>>, EmptyOptions, IncludeKeysForProperty>;
|
|
611
|
+
double: <Mode extends 'number' | 'string' = 'number'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.double<Mode>>, EmptyOptions, IncludeKeysForProperty>;
|
|
611
612
|
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
612
613
|
string: () => StringPropertyOptionsBuilder<InferPropertyValueType<typeof types.string>, EmptyOptions>;
|
|
613
614
|
text: () => StringPropertyOptionsBuilder<InferPropertyValueType<typeof types.text>, EmptyOptions>;
|
package/entity/defineEntity.js
CHANGED
|
@@ -519,6 +519,7 @@ const propertyBuilders = {
|
|
|
519
519
|
bigint: (mode) => new UniversalPropertyOptionsBuilder({ type: new types.bigint(mode) }),
|
|
520
520
|
array: (toJsValue = i => i, toDbValue = i => i) => new UniversalPropertyOptionsBuilder({ type: new types.array(toJsValue, toDbValue) }),
|
|
521
521
|
decimal: (mode) => new UniversalPropertyOptionsBuilder({ type: new types.decimal(mode) }),
|
|
522
|
+
double: (mode) => new UniversalPropertyOptionsBuilder({ type: new types.double(mode) }),
|
|
522
523
|
json: () => new UniversalPropertyOptionsBuilder({ type: types.json }),
|
|
523
524
|
string: () => new StringPropertyOptionsBuilder({
|
|
524
525
|
type: types.string,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.3.0-dev.
|
|
3
|
+
"version": "7.3.0-dev.17",
|
|
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",
|
package/types/DoubleType.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { Type } from './Type.js';
|
|
|
2
2
|
import type { Platform } from '../platforms/Platform.js';
|
|
3
3
|
import type { EntityProperty } from '../typings.js';
|
|
4
4
|
/**
|
|
5
|
-
* Type that maps an SQL DOUBLE to a JS
|
|
5
|
+
* Type that maps an SQL DOUBLE to a JS number (default) or string.
|
|
6
6
|
*/
|
|
7
|
-
export declare class DoubleType extends
|
|
8
|
-
|
|
7
|
+
export declare class DoubleType<Mode extends 'number' | 'string' = 'number'> extends Type<JSTypeByMode<Mode>, string> {
|
|
8
|
+
mode?: Mode | undefined;
|
|
9
|
+
constructor(mode?: Mode | undefined);
|
|
10
|
+
convertToJSValue(value: string): JSTypeByMode<Mode>;
|
|
9
11
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
10
12
|
compareAsType(): string;
|
|
11
13
|
}
|
|
14
|
+
type JSTypeByMode<Mode extends 'number' | 'string'> = Mode extends 'number' ? number : string;
|
|
15
|
+
export {};
|
package/types/DoubleType.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { Type } from './Type.js';
|
|
2
2
|
/**
|
|
3
|
-
* Type that maps an SQL DOUBLE to a JS
|
|
3
|
+
* Type that maps an SQL DOUBLE to a JS number (default) or string.
|
|
4
4
|
*/
|
|
5
5
|
export class DoubleType extends Type {
|
|
6
|
+
mode;
|
|
7
|
+
constructor(mode) {
|
|
8
|
+
super();
|
|
9
|
+
this.mode = mode;
|
|
10
|
+
}
|
|
6
11
|
/* v8 ignore next */
|
|
7
12
|
convertToJSValue(value) {
|
|
8
|
-
if (this.prop?.runtimeType === 'number') {
|
|
13
|
+
if ((this.mode ?? this.prop?.runtimeType) === 'number') {
|
|
9
14
|
return +value;
|
|
10
15
|
}
|
|
11
16
|
return String(value);
|
|
@@ -14,6 +19,6 @@ export class DoubleType extends Type {
|
|
|
14
19
|
return platform.getDoubleDeclarationSQL();
|
|
15
20
|
}
|
|
16
21
|
compareAsType() {
|
|
17
|
-
return this.prop?.runtimeType ?? 'number';
|
|
22
|
+
return this.mode ?? this.prop?.runtimeType ?? 'number';
|
|
18
23
|
}
|
|
19
24
|
}
|
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.3.0-dev.
|
|
156
|
+
static #ORM_VERSION = '7.3.0-dev.17';
|
|
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}`;
|