@mikro-orm/mssql 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/MsSqlConnection.js +1 -0
- package/MsSqlMikroORM.js +2 -2
- package/MsSqlPlatform.d.ts +6 -4
- package/MsSqlPlatform.js +14 -7
- package/MsSqlSchemaHelper.js +4 -4
- package/UnicodeCharacterType.d.ts +6 -0
- package/UnicodeCharacterType.js +14 -0
- package/UnicodeStringType.d.ts +5 -2
- package/UnicodeStringType.js +5 -2
- package/index.mjs +1 -0
- package/package.json +4 -4
package/MsSqlConnection.js
CHANGED
package/MsSqlMikroORM.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MsSqlMikroORM = void 0;
|
|
4
|
+
exports.defineMsSqlConfig = defineMsSqlConfig;
|
|
4
5
|
const core_1 = require("@mikro-orm/core");
|
|
5
6
|
const MsSqlDriver_1 = require("./MsSqlDriver");
|
|
6
7
|
/**
|
|
@@ -26,4 +27,3 @@ exports.MsSqlMikroORM = MsSqlMikroORM;
|
|
|
26
27
|
function defineMsSqlConfig(options) {
|
|
27
28
|
return (0, core_1.defineConfig)({ driver: MsSqlDriver_1.MsSqlDriver, ...options });
|
|
28
29
|
}
|
|
29
|
-
exports.defineMsSqlConfig = defineMsSqlConfig;
|
package/MsSqlPlatform.d.ts
CHANGED
|
@@ -23,16 +23,18 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
|
|
|
23
23
|
getRegExpOperator(): string;
|
|
24
24
|
getBlobDeclarationSQL(): string;
|
|
25
25
|
getJsonDeclarationSQL(): string;
|
|
26
|
+
getVarcharTypeDeclarationSQL(column: {
|
|
27
|
+
length?: number;
|
|
28
|
+
}): string;
|
|
26
29
|
getEnumTypeDeclarationSQL(column: {
|
|
27
|
-
fieldNames: string[];
|
|
28
30
|
items?: unknown[];
|
|
31
|
+
fieldNames: string[];
|
|
29
32
|
length?: number;
|
|
33
|
+
unsigned?: boolean;
|
|
34
|
+
autoincrement?: boolean;
|
|
30
35
|
}): string;
|
|
31
36
|
getDefaultMappedType(type: string): Type<unknown>;
|
|
32
37
|
getDefaultSchemaName(): string | undefined;
|
|
33
|
-
getVarcharTypeDeclarationSQL(column: {
|
|
34
|
-
length?: number;
|
|
35
|
-
}): string;
|
|
36
38
|
getUuidTypeDeclarationSQL(column: {
|
|
37
39
|
length?: number;
|
|
38
40
|
}): string;
|
package/MsSqlPlatform.js
CHANGED
|
@@ -10,6 +10,7 @@ const tsqlstring_1 = __importDefault(require("tsqlstring"));
|
|
|
10
10
|
const MsSqlSchemaHelper_1 = require("./MsSqlSchemaHelper");
|
|
11
11
|
const MsSqlExceptionConverter_1 = require("./MsSqlExceptionConverter");
|
|
12
12
|
const MsSqlSchemaGenerator_1 = require("./MsSqlSchemaGenerator");
|
|
13
|
+
const UnicodeCharacterType_1 = require("./UnicodeCharacterType");
|
|
13
14
|
const UnicodeStringType_1 = require("./UnicodeStringType");
|
|
14
15
|
class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
15
16
|
schemaHelper = new MsSqlSchemaHelper_1.MsSqlSchemaHelper(this);
|
|
@@ -26,7 +27,7 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
26
27
|
if (typeof value === 'string') {
|
|
27
28
|
return value;
|
|
28
29
|
}
|
|
29
|
-
return value.toISOString().substring(
|
|
30
|
+
return tsqlstring_1.default.dateToString(value.toISOString(), this.timezone ?? 'local').substring(1, 11);
|
|
30
31
|
}
|
|
31
32
|
convertsJsonAutomatically() {
|
|
32
33
|
return false;
|
|
@@ -65,9 +66,15 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
65
66
|
getJsonDeclarationSQL() {
|
|
66
67
|
return 'nvarchar(max)';
|
|
67
68
|
}
|
|
69
|
+
getVarcharTypeDeclarationSQL(column) {
|
|
70
|
+
if (column.length === -1) {
|
|
71
|
+
return 'varchar(max)';
|
|
72
|
+
}
|
|
73
|
+
return super.getVarcharTypeDeclarationSQL(column);
|
|
74
|
+
}
|
|
68
75
|
getEnumTypeDeclarationSQL(column) {
|
|
69
76
|
if (column.items?.every(item => knex_1.Utils.isString(item))) {
|
|
70
|
-
return
|
|
77
|
+
return knex_1.Type.getType(UnicodeStringType_1.UnicodeStringType).getColumnType({ length: 100, ...column }, this);
|
|
71
78
|
}
|
|
72
79
|
/* istanbul ignore next */
|
|
73
80
|
return this.getSmallIntTypeDeclarationSQL(column);
|
|
@@ -77,6 +84,9 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
77
84
|
if (normalizedType !== 'uuid' && ['string', 'nvarchar'].includes(normalizedType)) {
|
|
78
85
|
return knex_1.Type.getType(UnicodeStringType_1.UnicodeStringType);
|
|
79
86
|
}
|
|
87
|
+
if (['character', 'nchar'].includes(normalizedType)) {
|
|
88
|
+
return knex_1.Type.getType(UnicodeCharacterType_1.UnicodeCharacterType);
|
|
89
|
+
}
|
|
80
90
|
const map = {
|
|
81
91
|
int: 'integer',
|
|
82
92
|
bit: 'boolean',
|
|
@@ -90,9 +100,6 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
90
100
|
getDefaultSchemaName() {
|
|
91
101
|
return 'dbo';
|
|
92
102
|
}
|
|
93
|
-
getVarcharTypeDeclarationSQL(column) {
|
|
94
|
-
return `nvarchar(${column.length ?? 255})`;
|
|
95
|
-
}
|
|
96
103
|
getUuidTypeDeclarationSQL(column) {
|
|
97
104
|
return 'uniqueidentifier';
|
|
98
105
|
}
|
|
@@ -153,13 +160,13 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
153
160
|
}
|
|
154
161
|
/* istanbul ignore if */
|
|
155
162
|
if (knex_1.Utils.isPlainObject(value) || value?.[knex_1.JsonProperty]) {
|
|
156
|
-
return tsqlstring_1.default.escape(JSON.stringify(value), true, this.timezone);
|
|
163
|
+
return tsqlstring_1.default.escape(JSON.stringify(value), true, this.timezone ?? 'local');
|
|
157
164
|
}
|
|
158
165
|
if (value instanceof Buffer) {
|
|
159
166
|
return `0x${value.toString('hex')}`;
|
|
160
167
|
}
|
|
161
168
|
if (value instanceof Date) {
|
|
162
|
-
return tsqlstring_1.default.dateToString(value.toISOString(), '
|
|
169
|
+
return tsqlstring_1.default.dateToString(value.toISOString(), this.timezone ?? 'local');
|
|
163
170
|
}
|
|
164
171
|
return tsqlstring_1.default.escape(value);
|
|
165
172
|
}
|
package/MsSqlSchemaHelper.js
CHANGED
|
@@ -341,14 +341,14 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
341
341
|
return super.createTableColumn(table, column, fromTable, changedProperties);
|
|
342
342
|
}
|
|
343
343
|
inferLengthFromColumnType(type) {
|
|
344
|
-
const match = type.match(
|
|
344
|
+
const match = type.match(/^(\w+)\s*\(\s*(-?\d+|max)\s*\)/);
|
|
345
345
|
if (!match) {
|
|
346
|
-
return
|
|
346
|
+
return;
|
|
347
347
|
}
|
|
348
|
-
if (match[
|
|
348
|
+
if (match[2] === 'max') {
|
|
349
349
|
return -1;
|
|
350
350
|
}
|
|
351
|
-
return +match[
|
|
351
|
+
return +match[2];
|
|
352
352
|
}
|
|
353
353
|
wrap(val, type) {
|
|
354
354
|
const stringType = type instanceof knex_1.StringType || type instanceof knex_1.TextType || type instanceof knex_1.EnumType || type instanceof UnicodeStringType_1.UnicodeStringType;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Platform, EntityProperty } from '@mikro-orm/core';
|
|
2
|
+
import { UnicodeStringType } from './UnicodeStringType';
|
|
3
|
+
export declare class UnicodeCharacterType extends UnicodeStringType {
|
|
4
|
+
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
5
|
+
getDefaultLength(platform: Platform): number;
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnicodeCharacterType = void 0;
|
|
4
|
+
const UnicodeStringType_1 = require("./UnicodeStringType");
|
|
5
|
+
class UnicodeCharacterType extends UnicodeStringType_1.UnicodeStringType {
|
|
6
|
+
getColumnType(prop, platform) {
|
|
7
|
+
const length = prop.length === -1 ? 'max' : (prop.length ?? this.getDefaultLength(platform));
|
|
8
|
+
return `nchar(${length})`;
|
|
9
|
+
}
|
|
10
|
+
getDefaultLength(platform) {
|
|
11
|
+
return platform.getDefaultCharLength();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.UnicodeCharacterType = UnicodeCharacterType;
|
package/UnicodeStringType.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Platform, Type } from '@mikro-orm/core';
|
|
2
2
|
export declare class UnicodeString {
|
|
3
3
|
readonly value: string;
|
|
4
4
|
constructor(value: string);
|
|
@@ -8,9 +8,12 @@ export declare class UnicodeString {
|
|
|
8
8
|
[Symbol.toPrimitive](): string;
|
|
9
9
|
}
|
|
10
10
|
export declare class UnicodeStringType extends Type<string | null, string | null> {
|
|
11
|
-
getColumnType(prop:
|
|
11
|
+
getColumnType(prop: {
|
|
12
|
+
length?: number;
|
|
13
|
+
}, platform: Platform): string;
|
|
12
14
|
convertToJSValue(value: string | null | UnicodeString): string | null;
|
|
13
15
|
convertToDatabaseValue(value: string | null): string | null;
|
|
14
16
|
get runtimeType(): string;
|
|
15
17
|
toJSON(value: string | null | UnicodeString): string | null;
|
|
18
|
+
getDefaultLength(platform: Platform): number;
|
|
16
19
|
}
|
package/UnicodeStringType.js
CHANGED
|
@@ -22,8 +22,8 @@ class UnicodeString {
|
|
|
22
22
|
}
|
|
23
23
|
exports.UnicodeString = UnicodeString;
|
|
24
24
|
class UnicodeStringType extends core_1.Type {
|
|
25
|
-
getColumnType(prop) {
|
|
26
|
-
const length = prop.length === -1 ? 'max' : (prop.length ??
|
|
25
|
+
getColumnType(prop, platform) {
|
|
26
|
+
const length = prop.length === -1 ? 'max' : (prop.length ?? this.getDefaultLength(platform));
|
|
27
27
|
return `nvarchar(${length})`;
|
|
28
28
|
}
|
|
29
29
|
convertToJSValue(value) {
|
|
@@ -45,5 +45,8 @@ class UnicodeStringType extends core_1.Type {
|
|
|
45
45
|
toJSON(value) {
|
|
46
46
|
return this.convertToJSValue(value);
|
|
47
47
|
}
|
|
48
|
+
getDefaultLength(platform) {
|
|
49
|
+
return platform.getDefaultVarcharLength();
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
exports.UnicodeStringType = UnicodeStringType;
|
package/index.mjs
CHANGED
|
@@ -33,6 +33,7 @@ export const ChangeSet = mod.ChangeSet;
|
|
|
33
33
|
export const ChangeSetComputer = mod.ChangeSetComputer;
|
|
34
34
|
export const ChangeSetPersister = mod.ChangeSetPersister;
|
|
35
35
|
export const ChangeSetType = mod.ChangeSetType;
|
|
36
|
+
export const CharacterType = mod.CharacterType;
|
|
36
37
|
export const Check = mod.Check;
|
|
37
38
|
export const CheckConstraintViolationException = mod.CheckConstraintViolationException;
|
|
38
39
|
export const Collection = mod.Collection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mssql",
|
|
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",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@mikro-orm/knex": "6.2.10-dev.
|
|
62
|
-
"tedious": "18.2.
|
|
61
|
+
"@mikro-orm/knex": "6.2.10-dev.91",
|
|
62
|
+
"tedious": "18.2.3",
|
|
63
63
|
"tsqlstring": "1.0.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@mikro-orm/core": "^6.2.9"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.2.10-dev.
|
|
69
|
+
"@mikro-orm/core": "6.2.10-dev.91"
|
|
70
70
|
}
|
|
71
71
|
}
|