@mikro-orm/mssql 7.0.0-dev.334 → 7.0.0-dev.336
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/MsSqlPlatform.d.ts +5 -0
- package/MsSqlPlatform.js +14 -3
- package/package.json +3 -3
package/MsSqlPlatform.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { MsSqlExceptionConverter } from './MsSqlExceptionConverter.js';
|
|
|
4
4
|
import { MsSqlSchemaGenerator } from './MsSqlSchemaGenerator.js';
|
|
5
5
|
import type { MsSqlDriver } from './MsSqlDriver.js';
|
|
6
6
|
export declare class MsSqlPlatform extends AbstractSqlPlatform {
|
|
7
|
+
#private;
|
|
7
8
|
protected readonly schemaHelper: MsSqlSchemaHelper;
|
|
8
9
|
protected readonly exceptionConverter: MsSqlExceptionConverter;
|
|
9
10
|
/** @inheritDoc */
|
|
@@ -52,6 +53,10 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
|
|
|
52
53
|
}): string;
|
|
53
54
|
validateMetadata(meta: EntityMetadata): void;
|
|
54
55
|
getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | RawQueryFragment;
|
|
56
|
+
getJsonArrayFromSQL(column: string, alias: string, properties: {
|
|
57
|
+
name: string;
|
|
58
|
+
type: string;
|
|
59
|
+
}[]): string;
|
|
55
60
|
normalizePrimaryKey<T extends number | string = number | string>(data: Primary<T> | IPrimaryKey | string): T;
|
|
56
61
|
usesEnumCheckConstraints(): boolean;
|
|
57
62
|
supportsMultipleCascadePaths(): boolean;
|
package/MsSqlPlatform.js
CHANGED
|
@@ -9,6 +9,12 @@ import { UnicodeString, UnicodeStringType } from './UnicodeStringType.js';
|
|
|
9
9
|
export class MsSqlPlatform extends AbstractSqlPlatform {
|
|
10
10
|
schemaHelper = new MsSqlSchemaHelper(this);
|
|
11
11
|
exceptionConverter = new MsSqlExceptionConverter();
|
|
12
|
+
#jsonTypeCasts = {
|
|
13
|
+
string: 'nvarchar(max)',
|
|
14
|
+
number: 'float',
|
|
15
|
+
bigint: 'bigint',
|
|
16
|
+
boolean: 'bit',
|
|
17
|
+
};
|
|
12
18
|
/** @inheritDoc */
|
|
13
19
|
lookupExtensions(orm) {
|
|
14
20
|
MsSqlSchemaGenerator.register(orm);
|
|
@@ -148,12 +154,17 @@ export class MsSqlPlatform extends AbstractSqlPlatform {
|
|
|
148
154
|
boolean: 'bit',
|
|
149
155
|
};
|
|
150
156
|
const cast = (key) => raw(type in types ? `cast(${key} as ${types[type]})` : key);
|
|
151
|
-
const quoteKey = (key) => (/^[a-z]\w*$/i.exec(key) ? key : `"${key}"`);
|
|
152
157
|
/* v8 ignore next */
|
|
153
158
|
if (path.length === 0) {
|
|
154
|
-
return cast(`json_value(${root}, '$.${b.map(
|
|
159
|
+
return cast(`json_value(${root}, '$.${b.map(this.quoteJsonKey).join('.')}')`);
|
|
155
160
|
}
|
|
156
|
-
return cast(`json_value(${root}, '$.${b.map(
|
|
161
|
+
return cast(`json_value(${root}, '$.${b.map(this.quoteJsonKey).join('.')}')`);
|
|
162
|
+
}
|
|
163
|
+
getJsonArrayFromSQL(column, alias, properties) {
|
|
164
|
+
const columns = properties
|
|
165
|
+
.map(p => `${this.quoteIdentifier(p.name)} ${this.#jsonTypeCasts[p.type] ?? 'nvarchar(max)'} '$.${this.quoteJsonKey(p.name)}'`)
|
|
166
|
+
.join(', ');
|
|
167
|
+
return `openjson(${column}) with (${columns}) as ${this.quoteIdentifier(alias)}`;
|
|
157
168
|
}
|
|
158
169
|
normalizePrimaryKey(data) {
|
|
159
170
|
/* v8 ignore next */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mssql",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.336",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.0.0-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.0.0-dev.336",
|
|
51
51
|
"kysely": "0.28.11",
|
|
52
52
|
"tarn": "3.0.2",
|
|
53
53
|
"tedious": "19.2.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@mikro-orm/core": "^6.6.9"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
60
|
+
"@mikro-orm/core": "7.0.0-dev.336"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">= 22.17.0"
|