@mikro-orm/mssql 7.0.0-dev.1 → 7.0.0-dev.2
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 +10 -46
- package/MsSqlDriver.d.ts +2 -2
- package/MsSqlDriver.js +13 -23
- package/MsSqlExceptionConverter.js +10 -14
- package/MsSqlMikroORM.d.ts +1 -1
- package/MsSqlMikroORM.js +7 -12
- package/MsSqlPlatform.d.ts +3 -3
- package/MsSqlPlatform.js +36 -43
- package/MsSqlQueryBuilder.js +5 -9
- package/MsSqlSchemaGenerator.js +3 -7
- package/MsSqlSchemaHelper.js +20 -25
- package/UnicodeCharacterType.d.ts +1 -1
- package/UnicodeCharacterType.js +2 -6
- package/UnicodeStringType.js +4 -9
- package/index.d.ts +7 -7
- package/index.js +8 -28
- package/package.json +6 -14
- package/index.mjs +0 -239
package/MsSqlConnection.js
CHANGED
|
@@ -1,59 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.MsSqlConnection = void 0;
|
|
37
|
-
const knex_1 = require("@mikro-orm/knex");
|
|
38
|
-
const kysely_1 = require("kysely");
|
|
39
|
-
const Tedious = __importStar(require("tedious"));
|
|
40
|
-
const Tarn = __importStar(require("tarn"));
|
|
41
|
-
class MsSqlConnection extends knex_1.AbstractSqlConnection {
|
|
1
|
+
import { AbstractSqlConnection, Utils, } from '@mikro-orm/knex';
|
|
2
|
+
import { MssqlDialect } from 'kysely';
|
|
3
|
+
import * as Tedious from 'tedious';
|
|
4
|
+
import * as Tarn from 'tarn';
|
|
5
|
+
export class MsSqlConnection extends AbstractSqlConnection {
|
|
42
6
|
createKyselyDialect(overrides) {
|
|
43
7
|
const options = this.mapOptions(overrides);
|
|
44
|
-
const poolOptions =
|
|
8
|
+
const poolOptions = Utils.mergeConfig({
|
|
45
9
|
min: 0,
|
|
46
10
|
max: 10,
|
|
47
11
|
}, this.config.get('pool'));
|
|
48
12
|
const password = options.authentication?.options?.password;
|
|
49
13
|
const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
|
|
50
|
-
return new
|
|
14
|
+
return new MssqlDialect({
|
|
51
15
|
tarn: { ...Tarn, options: poolOptions },
|
|
52
16
|
tedious: {
|
|
53
17
|
...Tedious,
|
|
54
18
|
connectionFactory: async () => {
|
|
55
19
|
options.authentication.options.password = typeof password === 'function' ? await password() : password;
|
|
56
20
|
const connection = new Tedious.Connection(options);
|
|
21
|
+
/* v8 ignore next */
|
|
57
22
|
await onCreateConnection?.(connection);
|
|
58
23
|
return connection;
|
|
59
24
|
},
|
|
@@ -80,14 +45,14 @@ class MsSqlConnection extends knex_1.AbstractSqlConnection {
|
|
|
80
45
|
},
|
|
81
46
|
server: options.host,
|
|
82
47
|
};
|
|
83
|
-
/*
|
|
48
|
+
/* v8 ignore next 6 */
|
|
84
49
|
if (ret.server.includes('\\')) {
|
|
85
50
|
const [host, ...name] = ret.server.split('\\');
|
|
86
51
|
ret.server = host;
|
|
87
52
|
ret.options.instanceName = name.join('\\');
|
|
88
53
|
delete ret.options.port;
|
|
89
54
|
}
|
|
90
|
-
return
|
|
55
|
+
return Utils.mergeConfig(ret, overrides);
|
|
91
56
|
}
|
|
92
57
|
async commit(ctx, eventBroadcaster) {
|
|
93
58
|
if ('savepointName' in ctx) {
|
|
@@ -112,4 +77,3 @@ class MsSqlConnection extends knex_1.AbstractSqlConnection {
|
|
|
112
77
|
};
|
|
113
78
|
}
|
|
114
79
|
}
|
|
115
|
-
exports.MsSqlConnection = MsSqlConnection;
|
package/MsSqlDriver.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction } from '@mikro-orm/core';
|
|
2
2
|
import { AbstractSqlDriver, type SqlEntityManager } from '@mikro-orm/knex';
|
|
3
|
-
import { MsSqlConnection } from './MsSqlConnection';
|
|
4
|
-
import { MsSqlQueryBuilder } from './MsSqlQueryBuilder';
|
|
3
|
+
import { MsSqlConnection } from './MsSqlConnection.js';
|
|
4
|
+
import { MsSqlQueryBuilder } from './MsSqlQueryBuilder.js';
|
|
5
5
|
export declare class MsSqlDriver extends AbstractSqlDriver<MsSqlConnection> {
|
|
6
6
|
constructor(config: Configuration);
|
|
7
7
|
nativeInsertMany<T extends AnyEntity<T>>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
|
package/MsSqlDriver.js
CHANGED
|
@@ -1,42 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const MsSqlPlatform_1 = require("./MsSqlPlatform");
|
|
8
|
-
const MsSqlQueryBuilder_1 = require("./MsSqlQueryBuilder");
|
|
9
|
-
class MsSqlDriver extends knex_1.AbstractSqlDriver {
|
|
1
|
+
import { QueryFlag, Utils, } from '@mikro-orm/core';
|
|
2
|
+
import { AbstractSqlDriver } from '@mikro-orm/knex';
|
|
3
|
+
import { MsSqlConnection } from './MsSqlConnection.js';
|
|
4
|
+
import { MsSqlPlatform } from './MsSqlPlatform.js';
|
|
5
|
+
import { MsSqlQueryBuilder } from './MsSqlQueryBuilder.js';
|
|
6
|
+
export class MsSqlDriver extends AbstractSqlDriver {
|
|
10
7
|
constructor(config) {
|
|
11
|
-
super(config, new
|
|
8
|
+
super(config, new MsSqlPlatform(), MsSqlConnection, ['kysely', 'tedious']);
|
|
12
9
|
}
|
|
13
10
|
async nativeInsertMany(entityName, data, options = {}) {
|
|
14
11
|
const meta = this.metadata.get(entityName);
|
|
15
12
|
const keys = new Set();
|
|
16
13
|
data.forEach(row => Object.keys(row).forEach(k => keys.add(k)));
|
|
17
14
|
const props = [...keys].map(name => meta.properties[name] ?? { name, fieldNames: [name] });
|
|
18
|
-
const fields =
|
|
15
|
+
const fields = Utils.flatten(props.map(prop => prop.fieldNames));
|
|
19
16
|
const tableName = this.getTableName(meta, options);
|
|
20
17
|
const hasFields = fields.length > 0;
|
|
21
18
|
// Is this en empty insert... this is rather hard in mssql (especially with an insert many)
|
|
22
19
|
if (!hasFields) {
|
|
23
20
|
const returningProps = meta.props.filter(prop => prop.primary || prop.defaultRaw);
|
|
24
|
-
const returningFields =
|
|
21
|
+
const returningFields = Utils.flatten(returningProps.map(prop => prop.fieldNames));
|
|
25
22
|
const using2 = `select * from (values ${data.map((x, i) => `(${i})`).join(',')}) v (id) where 1 = 1`;
|
|
26
|
-
/*
|
|
23
|
+
/* v8 ignore next */
|
|
27
24
|
const output = returningFields.length > 0 ? `output ${returningFields.map(field => 'inserted.' + this.platform.quoteIdentifier(field)).join(', ')}` : '';
|
|
28
25
|
const sql = `merge into ${tableName} using (${using2}) s on 1 = 0 when not matched then insert default values ${output};`;
|
|
29
26
|
const res = await this.execute(sql, [], 'run', options.ctx);
|
|
30
27
|
const pks = this.getPrimaryKeyFields(entityName);
|
|
31
|
-
|
|
32
|
-
/* istanbul ignore next */
|
|
33
|
-
if (pks.length > 1) { // owner has composite pk
|
|
34
|
-
pk = data.map(d => core_1.Utils.getPrimaryKeyCond(d, pks));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
28
|
+
if (pks.length === 1) {
|
|
37
29
|
res.row ??= {};
|
|
38
30
|
res.rows ??= [];
|
|
39
|
-
pk = data.map((d, i) => d[pks[0]] ?? res.rows[i]?.[pks[0]]).map(d => [d]);
|
|
40
31
|
res.insertId = res.insertId || res.row[pks[0]];
|
|
41
32
|
}
|
|
42
33
|
return res;
|
|
@@ -51,11 +42,10 @@ class MsSqlDriver extends knex_1.AbstractSqlDriver {
|
|
|
51
42
|
createQueryBuilder(entityName, ctx, preferredConnectionType, convertCustomTypes, loggerContext, alias, em) {
|
|
52
43
|
// do not compute the connectionType if EM is provided as it will be computed from it in the QB later on
|
|
53
44
|
const connectionType = em ? preferredConnectionType : this.resolveConnectionType({ ctx, connectionType: preferredConnectionType });
|
|
54
|
-
const qb = new
|
|
45
|
+
const qb = new MsSqlQueryBuilder(entityName, this.metadata, this, ctx, alias, connectionType, em, loggerContext);
|
|
55
46
|
if (!convertCustomTypes) {
|
|
56
|
-
qb.unsetFlag(
|
|
47
|
+
qb.unsetFlag(QueryFlag.CONVERT_CUSTOM_TYPES);
|
|
57
48
|
}
|
|
58
49
|
return qb;
|
|
59
50
|
}
|
|
60
51
|
}
|
|
61
|
-
exports.MsSqlDriver = MsSqlDriver;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MsSqlExceptionConverter = void 0;
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
class MsSqlExceptionConverter extends core_1.ExceptionConverter {
|
|
6
|
-
/* istanbul ignore next */
|
|
1
|
+
import { ExceptionConverter, InvalidFieldNameException, NonUniqueFieldNameException, NotNullConstraintViolationException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, } from '@mikro-orm/core';
|
|
2
|
+
export class MsSqlExceptionConverter extends ExceptionConverter {
|
|
7
3
|
/**
|
|
8
4
|
* @link https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-511-database-engine-error?view=sql-server-ver15
|
|
9
5
|
* @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
|
|
10
6
|
*/
|
|
11
7
|
convertException(exception) {
|
|
12
8
|
let errno = exception.number;
|
|
9
|
+
/* v8 ignore next 5 */
|
|
13
10
|
if ('errors' in exception && Array.isArray(exception.errors) && typeof exception.errors[0] === 'object' && 'message' in exception.errors[0]) {
|
|
14
11
|
exception.message += '\n' + exception.errors.map(e => e.message).join('\n');
|
|
15
12
|
errno ??= exception.errors[0].number;
|
|
@@ -17,21 +14,20 @@ class MsSqlExceptionConverter extends core_1.ExceptionConverter {
|
|
|
17
14
|
}
|
|
18
15
|
switch (errno) {
|
|
19
16
|
case 515:
|
|
20
|
-
return new
|
|
17
|
+
return new NotNullConstraintViolationException(exception);
|
|
21
18
|
case 102:
|
|
22
|
-
return new
|
|
19
|
+
return new SyntaxErrorException(exception);
|
|
23
20
|
case 207:
|
|
24
|
-
return new
|
|
21
|
+
return new InvalidFieldNameException(exception);
|
|
25
22
|
case 208:
|
|
26
|
-
return new
|
|
23
|
+
return new TableNotFoundException(exception);
|
|
27
24
|
case 209:
|
|
28
|
-
return new
|
|
25
|
+
return new NonUniqueFieldNameException(exception);
|
|
29
26
|
case 2601:
|
|
30
|
-
return new
|
|
27
|
+
return new UniqueConstraintViolationException(exception);
|
|
31
28
|
case 2714:
|
|
32
|
-
return new
|
|
29
|
+
return new TableExistsException(exception);
|
|
33
30
|
}
|
|
34
31
|
return super.convertException(exception);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.MsSqlExceptionConverter = MsSqlExceptionConverter;
|
package/MsSqlMikroORM.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
|
|
2
|
-
import { MsSqlDriver } from './MsSqlDriver';
|
|
2
|
+
import { MsSqlDriver } from './MsSqlDriver.js';
|
|
3
3
|
import type { SqlEntityManager } from '@mikro-orm/knex';
|
|
4
4
|
/**
|
|
5
5
|
* @inheritDoc
|
package/MsSqlMikroORM.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MsSqlMikroORM = void 0;
|
|
4
|
-
exports.defineMsSqlConfig = defineMsSqlConfig;
|
|
5
|
-
const core_1 = require("@mikro-orm/core");
|
|
6
|
-
const MsSqlDriver_1 = require("./MsSqlDriver");
|
|
1
|
+
import { defineConfig, MikroORM, } from '@mikro-orm/core';
|
|
2
|
+
import { MsSqlDriver } from './MsSqlDriver.js';
|
|
7
3
|
/**
|
|
8
4
|
* @inheritDoc
|
|
9
5
|
*/
|
|
10
|
-
class MsSqlMikroORM extends
|
|
11
|
-
static DRIVER =
|
|
6
|
+
export class MsSqlMikroORM extends MikroORM {
|
|
7
|
+
static DRIVER = MsSqlDriver;
|
|
12
8
|
/**
|
|
13
9
|
* @inheritDoc
|
|
14
10
|
*/
|
|
@@ -22,8 +18,7 @@ class MsSqlMikroORM extends core_1.MikroORM {
|
|
|
22
18
|
return super.initSync(options);
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return (0, core_1.defineConfig)({ driver: MsSqlDriver_1.MsSqlDriver, ...options });
|
|
21
|
+
/* v8 ignore next 3 */
|
|
22
|
+
export function defineMsSqlConfig(options) {
|
|
23
|
+
return defineConfig({ driver: MsSqlDriver, ...options });
|
|
29
24
|
}
|
package/MsSqlPlatform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractSqlPlatform, type EntityMetadata, type IDatabaseDriver, type EntityManager, type MikroORM, Type, type Primary, type IPrimaryKey, MsSqlNativeQueryBuilder } from '@mikro-orm/knex';
|
|
2
|
-
import { MsSqlSchemaHelper } from './MsSqlSchemaHelper';
|
|
3
|
-
import { MsSqlExceptionConverter } from './MsSqlExceptionConverter';
|
|
4
|
-
import { MsSqlSchemaGenerator } from './MsSqlSchemaGenerator';
|
|
2
|
+
import { MsSqlSchemaHelper } from './MsSqlSchemaHelper.js';
|
|
3
|
+
import { MsSqlExceptionConverter } from './MsSqlExceptionConverter.js';
|
|
4
|
+
import { MsSqlSchemaGenerator } from './MsSqlSchemaGenerator.js';
|
|
5
5
|
export declare class MsSqlPlatform extends AbstractSqlPlatform {
|
|
6
6
|
protected readonly schemaHelper: MsSqlSchemaHelper;
|
|
7
7
|
protected readonly exceptionConverter: MsSqlExceptionConverter;
|
package/MsSqlPlatform.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MsSqlPlatform = void 0;
|
|
7
|
-
const knex_1 = require("@mikro-orm/knex");
|
|
1
|
+
import { AbstractSqlPlatform, raw, Type, Utils, ALIAS_REPLACEMENT, DoubleType, FloatType, RawQueryFragment, MsSqlNativeQueryBuilder, } from '@mikro-orm/knex';
|
|
8
2
|
// @ts-expect-error no types available
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class MsSqlPlatform extends
|
|
16
|
-
schemaHelper = new
|
|
17
|
-
exceptionConverter = new
|
|
3
|
+
import SqlString from 'tsqlstring';
|
|
4
|
+
import { MsSqlSchemaHelper } from './MsSqlSchemaHelper.js';
|
|
5
|
+
import { MsSqlExceptionConverter } from './MsSqlExceptionConverter.js';
|
|
6
|
+
import { MsSqlSchemaGenerator } from './MsSqlSchemaGenerator.js';
|
|
7
|
+
import { UnicodeCharacterType } from './UnicodeCharacterType.js';
|
|
8
|
+
import { UnicodeString, UnicodeStringType } from './UnicodeStringType.js';
|
|
9
|
+
export class MsSqlPlatform extends AbstractSqlPlatform {
|
|
10
|
+
schemaHelper = new MsSqlSchemaHelper(this);
|
|
11
|
+
exceptionConverter = new MsSqlExceptionConverter();
|
|
18
12
|
/** @inheritDoc */
|
|
19
13
|
lookupExtensions(orm) {
|
|
20
|
-
|
|
14
|
+
MsSqlSchemaGenerator.register(orm);
|
|
21
15
|
}
|
|
22
16
|
/** @inheritDoc */
|
|
23
17
|
init(orm) {
|
|
24
18
|
super.init(orm);
|
|
25
19
|
// do not double escape backslash inside strings
|
|
26
|
-
|
|
20
|
+
SqlString.CHARS_GLOBAL_REGEXP = /'/g;
|
|
27
21
|
}
|
|
28
22
|
getRollbackToSavepointSQL(savepointName) {
|
|
29
23
|
return `rollback transaction ${this.quoteIdentifier(savepointName)}`;
|
|
@@ -33,17 +27,17 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
33
27
|
}
|
|
34
28
|
/** @internal */
|
|
35
29
|
createNativeQueryBuilder() {
|
|
36
|
-
return new
|
|
30
|
+
return new MsSqlNativeQueryBuilder(this);
|
|
37
31
|
}
|
|
38
32
|
usesOutputStatement() {
|
|
39
33
|
return true;
|
|
40
34
|
}
|
|
41
35
|
convertDateToJSValue(value) {
|
|
42
|
-
/*
|
|
36
|
+
/* v8 ignore next 3 */
|
|
43
37
|
if (typeof value === 'string') {
|
|
44
38
|
return value;
|
|
45
39
|
}
|
|
46
|
-
return
|
|
40
|
+
return SqlString.dateToString(value.toISOString(), this.timezone ?? 'local').substring(1, 11);
|
|
47
41
|
}
|
|
48
42
|
convertsJsonAutomatically() {
|
|
49
43
|
return false;
|
|
@@ -58,7 +52,7 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
58
52
|
return `current_timestamp`;
|
|
59
53
|
}
|
|
60
54
|
getDateTimeTypeDeclarationSQL(column) {
|
|
61
|
-
/*
|
|
55
|
+
/* v8 ignore next */
|
|
62
56
|
return 'datetime2' + (column.length != null ? `(${column.length})` : '');
|
|
63
57
|
}
|
|
64
58
|
getDefaultDateTimeLength() {
|
|
@@ -89,10 +83,10 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
89
83
|
return super.getVarcharTypeDeclarationSQL(column);
|
|
90
84
|
}
|
|
91
85
|
getEnumTypeDeclarationSQL(column) {
|
|
92
|
-
if (column.items?.every(item =>
|
|
93
|
-
return
|
|
86
|
+
if (column.items?.every(item => Utils.isString(item))) {
|
|
87
|
+
return Type.getType(UnicodeStringType).getColumnType({ length: 100, ...column }, this);
|
|
94
88
|
}
|
|
95
|
-
/*
|
|
89
|
+
/* v8 ignore next */
|
|
96
90
|
return this.getSmallIntTypeDeclarationSQL(column);
|
|
97
91
|
}
|
|
98
92
|
normalizeColumnType(type, options) {
|
|
@@ -108,14 +102,14 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
108
102
|
getDefaultMappedType(type) {
|
|
109
103
|
if (type.startsWith('float')) {
|
|
110
104
|
const len = type.match(/float\((\d+)\)/)?.[1] ?? 24;
|
|
111
|
-
return +len > 24 ?
|
|
105
|
+
return +len > 24 ? Type.getType(DoubleType) : Type.getType(FloatType);
|
|
112
106
|
}
|
|
113
107
|
const normalizedType = this.extractSimpleType(type);
|
|
114
108
|
if (normalizedType !== 'uuid' && ['string', 'nvarchar'].includes(normalizedType)) {
|
|
115
|
-
return
|
|
109
|
+
return Type.getType(UnicodeStringType);
|
|
116
110
|
}
|
|
117
111
|
if (['character', 'nchar'].includes(normalizedType)) {
|
|
118
|
-
return
|
|
112
|
+
return Type.getType(UnicodeCharacterType);
|
|
119
113
|
}
|
|
120
114
|
const map = {
|
|
121
115
|
int: 'integer',
|
|
@@ -139,7 +133,7 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
139
133
|
if ((prop.runtimeType === 'string' || ['string', 'nvarchar'].includes(prop.type))
|
|
140
134
|
&& !['uuid'].includes(prop.type)
|
|
141
135
|
&& !prop.columnTypes[0].startsWith('varchar')) {
|
|
142
|
-
prop.customType ??= new
|
|
136
|
+
prop.customType ??= new UnicodeStringType();
|
|
143
137
|
prop.customType.prop = prop;
|
|
144
138
|
prop.customType.platform = this;
|
|
145
139
|
prop.customType.meta = meta;
|
|
@@ -148,22 +142,22 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
148
142
|
}
|
|
149
143
|
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
150
144
|
const [a, ...b] = path;
|
|
151
|
-
/*
|
|
152
|
-
const root = this.quoteIdentifier(aliased ? `${
|
|
145
|
+
/* v8 ignore next */
|
|
146
|
+
const root = this.quoteIdentifier(aliased ? `${ALIAS_REPLACEMENT}.${a}` : a);
|
|
153
147
|
const types = {
|
|
154
148
|
boolean: 'bit',
|
|
155
149
|
};
|
|
156
|
-
const cast = (key) =>
|
|
150
|
+
const cast = (key) => raw(type in types ? `cast(${key} as ${types[type]})` : key);
|
|
157
151
|
const quoteKey = (key) => key.match(/^[a-z]\w*$/i) ? key : `"${key}"`;
|
|
158
|
-
/*
|
|
152
|
+
/* v8 ignore next 3 */
|
|
159
153
|
if (path.length === 0) {
|
|
160
154
|
return cast(`json_value(${root}, '$.${b.map(quoteKey).join('.')}')`);
|
|
161
155
|
}
|
|
162
156
|
return cast(`json_value(${root}, '$.${b.map(quoteKey).join('.')}')`);
|
|
163
157
|
}
|
|
164
158
|
normalizePrimaryKey(data) {
|
|
165
|
-
/*
|
|
166
|
-
if (data instanceof
|
|
159
|
+
/* v8 ignore next 3 */
|
|
160
|
+
if (data instanceof UnicodeString) {
|
|
167
161
|
return data.value;
|
|
168
162
|
}
|
|
169
163
|
return data;
|
|
@@ -178,26 +172,26 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
178
172
|
return true;
|
|
179
173
|
}
|
|
180
174
|
quoteIdentifier(id) {
|
|
181
|
-
if (
|
|
175
|
+
if (RawQueryFragment.isKnownFragment(id)) {
|
|
182
176
|
return super.quoteIdentifier(id);
|
|
183
177
|
}
|
|
184
178
|
return `[${id.replace('.', `].[`)}]`;
|
|
185
179
|
}
|
|
186
180
|
escape(value) {
|
|
187
|
-
if (value instanceof
|
|
188
|
-
return `N${
|
|
181
|
+
if (value instanceof UnicodeString) {
|
|
182
|
+
return `N${SqlString.escape(value.value)}`;
|
|
189
183
|
}
|
|
190
184
|
if (value instanceof Buffer) {
|
|
191
185
|
return `0x${value.toString('hex')}`;
|
|
192
186
|
}
|
|
193
187
|
if (value instanceof Date) {
|
|
194
|
-
return
|
|
188
|
+
return SqlString.dateToString(value.toISOString(), this.timezone ?? 'local');
|
|
195
189
|
}
|
|
196
|
-
return
|
|
190
|
+
return SqlString.escape(value);
|
|
197
191
|
}
|
|
198
|
-
/*
|
|
192
|
+
/* v8 ignore next 3: kept for type inference only */
|
|
199
193
|
getSchemaGenerator(driver, em) {
|
|
200
|
-
return new
|
|
194
|
+
return new MsSqlSchemaGenerator(em ?? driver);
|
|
201
195
|
}
|
|
202
196
|
allowsComparingTuples() {
|
|
203
197
|
return false;
|
|
@@ -206,4 +200,3 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
206
200
|
return 'mssql://sa@localhost:1433';
|
|
207
201
|
}
|
|
208
202
|
}
|
|
209
|
-
exports.MsSqlPlatform = MsSqlPlatform;
|
package/MsSqlQueryBuilder.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
const knex_1 = require("@mikro-orm/knex");
|
|
6
|
-
class MsSqlQueryBuilder extends knex_1.QueryBuilder {
|
|
1
|
+
import { QueryFlag, Utils } from '@mikro-orm/core';
|
|
2
|
+
import { QueryBuilder } from '@mikro-orm/knex';
|
|
3
|
+
export class MsSqlQueryBuilder extends QueryBuilder {
|
|
7
4
|
insert(data) {
|
|
8
5
|
this.checkIdentityInsert(data);
|
|
9
6
|
return super.insert(data);
|
|
@@ -13,11 +10,10 @@ class MsSqlQueryBuilder extends knex_1.QueryBuilder {
|
|
|
13
10
|
if (!meta) {
|
|
14
11
|
return;
|
|
15
12
|
}
|
|
16
|
-
const dataKeys =
|
|
13
|
+
const dataKeys = Utils.unique(Utils.asArray(data).flatMap(Object.keys));
|
|
17
14
|
const hasAutoincrement = dataKeys.some(x => meta.properties[x]?.autoincrement);
|
|
18
15
|
if (hasAutoincrement) {
|
|
19
|
-
this.setFlag(
|
|
16
|
+
this.setFlag(QueryFlag.IDENTITY_INSERT);
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
exports.MsSqlQueryBuilder = MsSqlQueryBuilder;
|
package/MsSqlSchemaGenerator.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MsSqlSchemaGenerator = void 0;
|
|
4
|
-
const knex_1 = require("@mikro-orm/knex");
|
|
5
|
-
class MsSqlSchemaGenerator extends knex_1.SchemaGenerator {
|
|
1
|
+
import { SchemaGenerator } from '@mikro-orm/knex';
|
|
2
|
+
export class MsSqlSchemaGenerator extends SchemaGenerator {
|
|
6
3
|
static register(orm) {
|
|
7
4
|
orm.config.registerExtension('@mikro-orm/schema-generator', () => new MsSqlSchemaGenerator(orm.em));
|
|
8
5
|
}
|
|
9
6
|
async clearDatabase(options) {
|
|
10
7
|
// truncate by default, so no value is considered as true
|
|
11
|
-
/*
|
|
8
|
+
/* v8 ignore next 3 */
|
|
12
9
|
if (options?.truncate === false) {
|
|
13
10
|
return super.clearDatabase(options);
|
|
14
11
|
}
|
|
@@ -28,4 +25,3 @@ class MsSqlSchemaGenerator extends knex_1.SchemaGenerator {
|
|
|
28
25
|
return super.getDropSchemaSQL({ dropForeignKeys: true, ...options });
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
exports.MsSqlSchemaGenerator = MsSqlSchemaGenerator;
|
package/MsSqlSchemaHelper.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const knex_1 = require("@mikro-orm/knex");
|
|
5
|
-
const UnicodeStringType_1 = require("./UnicodeStringType");
|
|
6
|
-
class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
1
|
+
import { EnumType, SchemaHelper, StringType, TextType, Utils, } from '@mikro-orm/knex';
|
|
2
|
+
import { UnicodeStringType } from './UnicodeStringType.js';
|
|
3
|
+
export class MsSqlSchemaHelper extends SchemaHelper {
|
|
7
4
|
static DEFAULT_VALUES = {
|
|
8
5
|
'true': ['1'],
|
|
9
6
|
'false': ['0'],
|
|
@@ -79,7 +76,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
79
76
|
const defaultValue = str(this.normalizeDefaultValue(col.column_default, col.length, {}, true));
|
|
80
77
|
const increments = col.is_identity === 1 && connection.getPlatform().isNumericColumn(mappedType);
|
|
81
78
|
const key = this.getTableKey(col);
|
|
82
|
-
/*
|
|
79
|
+
/* v8 ignore next */
|
|
83
80
|
const generated = col.generation_expression ? `${col.generation_expression}${col.is_persisted ? ' persisted' : ''}` : undefined;
|
|
84
81
|
let type = col.data_type;
|
|
85
82
|
if (['varchar', 'nvarchar', 'char', 'nchar', 'varbinary'].includes(col.data_type)) {
|
|
@@ -156,9 +153,9 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
156
153
|
}
|
|
157
154
|
mapForeignKeys(fks, tableName, schemaName) {
|
|
158
155
|
const ret = super.mapForeignKeys(fks, tableName, schemaName);
|
|
159
|
-
for (const fk of
|
|
160
|
-
fk.columnNames =
|
|
161
|
-
fk.referencedColumnNames =
|
|
156
|
+
for (const fk of Utils.values(ret)) {
|
|
157
|
+
fk.columnNames = Utils.unique(fk.columnNames);
|
|
158
|
+
fk.referencedColumnNames = Utils.unique(fk.referencedColumnNames);
|
|
162
159
|
}
|
|
163
160
|
return ret;
|
|
164
161
|
}
|
|
@@ -193,7 +190,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
193
190
|
// `([type]='owner' OR [type]='manager' OR [type]='employee')`
|
|
194
191
|
const m1 = item.definition?.match(/^check \((.*)\)/);
|
|
195
192
|
let items = m1?.[1].split(' OR ');
|
|
196
|
-
/*
|
|
193
|
+
/* v8 ignore next */
|
|
197
194
|
const hasItems = (items?.length ?? 0) > 0;
|
|
198
195
|
if (item.columnName && hasItems) {
|
|
199
196
|
items = items.map(val => val.trim().replace(`[${item.columnName}]=`, '').match(/^\(?'(.*)'/)?.[1]).filter(Boolean);
|
|
@@ -256,7 +253,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
256
253
|
const parts = tableDiff.name.split('.');
|
|
257
254
|
const tableName = parts.pop();
|
|
258
255
|
const schemaName = parts.pop();
|
|
259
|
-
/*
|
|
256
|
+
/* v8 ignore next */
|
|
260
257
|
const name = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName;
|
|
261
258
|
const quotedName = this.quote(name);
|
|
262
259
|
// indexes need to be first dropped to be able to change a column type
|
|
@@ -281,7 +278,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
281
278
|
const parts = tableDiff.name.split('.');
|
|
282
279
|
const tableName = parts.pop();
|
|
283
280
|
const schemaName = parts.pop();
|
|
284
|
-
/*
|
|
281
|
+
/* v8 ignore next */
|
|
285
282
|
const name = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName;
|
|
286
283
|
// indexes need to be first dropped to be able to change a column type
|
|
287
284
|
const changedTypes = Object.values(tableDiff.changedColumns).filter(col => col.changedProperties.has('type'));
|
|
@@ -310,7 +307,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
310
307
|
return `drop index ${this.quote(oldIndexName)} on ${this.quote(table)}`;
|
|
311
308
|
}
|
|
312
309
|
getDropColumnsSQL(tableName, columns, schemaName) {
|
|
313
|
-
/*
|
|
310
|
+
/* v8 ignore next */
|
|
314
311
|
const tableNameRaw = this.quote((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
|
|
315
312
|
const drops = [];
|
|
316
313
|
const constraints = this.getDropDefaultsSQL(tableName, columns, schemaName);
|
|
@@ -320,7 +317,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
320
317
|
return `${constraints.join(';\n')};\nalter table ${tableNameRaw} drop column ${drops.join(', ')}`;
|
|
321
318
|
}
|
|
322
319
|
getDropDefaultsSQL(tableName, columns, schemaName) {
|
|
323
|
-
/*
|
|
320
|
+
/* v8 ignore next */
|
|
324
321
|
const tableNameRaw = this.quote((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
|
|
325
322
|
const constraints = [];
|
|
326
323
|
schemaName ??= this.platform.getDefaultSchemaName();
|
|
@@ -331,7 +328,6 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
331
328
|
}
|
|
332
329
|
const i = globalThis.idx;
|
|
333
330
|
globalThis.idx++;
|
|
334
|
-
/* istanbul ignore next */
|
|
335
331
|
constraints.push(`declare @constraint${i} varchar(100) = (select default_constraints.name from sys.all_columns`
|
|
336
332
|
+ ' join sys.tables on all_columns.object_id = tables.object_id'
|
|
337
333
|
+ ' join sys.schemas on tables.schema_id = schemas.schema_id'
|
|
@@ -342,7 +338,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
342
338
|
return constraints;
|
|
343
339
|
}
|
|
344
340
|
getRenameColumnSQL(tableName, oldColumnName, to, schemaName) {
|
|
345
|
-
/*
|
|
341
|
+
/* v8 ignore next */
|
|
346
342
|
const oldName = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName + '.' + oldColumnName;
|
|
347
343
|
const columnName = this.platform.quoteValue(to.name);
|
|
348
344
|
return `exec sp_rename ${this.platform.quoteValue(oldName)}, ${columnName}, 'COLUMN'`;
|
|
@@ -358,15 +354,15 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
358
354
|
else {
|
|
359
355
|
col.push(columnType);
|
|
360
356
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
357
|
+
Utils.runIfNotEmpty(() => col.push('identity(1,1)'), column.autoincrement);
|
|
358
|
+
Utils.runIfNotEmpty(() => col.push('null'), column.nullable);
|
|
359
|
+
Utils.runIfNotEmpty(() => col.push('not null'), !column.nullable && !column.generated);
|
|
364
360
|
if (column.autoincrement && !column.generated && !compositePK && (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
|
|
365
|
-
|
|
361
|
+
Utils.runIfNotEmpty(() => col.push('primary key'), primaryKey && column.primary);
|
|
366
362
|
}
|
|
367
363
|
const useDefault = changedProperties ? false : column.default != null && column.default !== 'null' && !column.autoincrement;
|
|
368
364
|
const defaultName = this.platform.getConfig().getNamingStrategy().indexName(table.name, [column.name], 'default');
|
|
369
|
-
|
|
365
|
+
Utils.runIfNotEmpty(() => col.push(`constraint ${this.quote(defaultName)} default ${column.default}`), useDefault);
|
|
370
366
|
return col.join(' ');
|
|
371
367
|
}
|
|
372
368
|
alterTableColumn(column, table, changedProperties) {
|
|
@@ -386,7 +382,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
386
382
|
return parts;
|
|
387
383
|
}
|
|
388
384
|
getCreateIndexSQL(tableName, index, partialExpression = false) {
|
|
389
|
-
/*
|
|
385
|
+
/* v8 ignore next 3 */
|
|
390
386
|
if (index.expression && !partialExpression) {
|
|
391
387
|
return index.expression;
|
|
392
388
|
}
|
|
@@ -462,8 +458,7 @@ else
|
|
|
462
458
|
return +match[2];
|
|
463
459
|
}
|
|
464
460
|
wrap(val, type) {
|
|
465
|
-
const stringType = type instanceof
|
|
461
|
+
const stringType = type instanceof StringType || type instanceof TextType || type instanceof EnumType || type instanceof UnicodeStringType;
|
|
466
462
|
return typeof val === 'string' && val.length > 0 && stringType ? this.platform.quoteValue(val) : val;
|
|
467
463
|
}
|
|
468
464
|
}
|
|
469
|
-
exports.MsSqlSchemaHelper = MsSqlSchemaHelper;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Platform, EntityProperty } from '@mikro-orm/core';
|
|
2
|
-
import { UnicodeStringType } from './UnicodeStringType';
|
|
2
|
+
import { UnicodeStringType } from './UnicodeStringType.js';
|
|
3
3
|
export declare class UnicodeCharacterType extends UnicodeStringType {
|
|
4
4
|
getColumnType(prop: EntityProperty, platform: Platform): string;
|
|
5
5
|
getDefaultLength(platform: Platform): number;
|
package/UnicodeCharacterType.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UnicodeCharacterType = void 0;
|
|
4
|
-
const UnicodeStringType_1 = require("./UnicodeStringType");
|
|
5
|
-
class UnicodeCharacterType extends UnicodeStringType_1.UnicodeStringType {
|
|
1
|
+
import { UnicodeStringType } from './UnicodeStringType.js';
|
|
2
|
+
export class UnicodeCharacterType extends UnicodeStringType {
|
|
6
3
|
getColumnType(prop, platform) {
|
|
7
4
|
const length = prop.length === -1 ? 'max' : (prop.length ?? this.getDefaultLength(platform));
|
|
8
5
|
return `nchar(${length})`;
|
|
@@ -11,4 +8,3 @@ class UnicodeCharacterType extends UnicodeStringType_1.UnicodeStringType {
|
|
|
11
8
|
return platform.getDefaultCharLength();
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
exports.UnicodeCharacterType = UnicodeCharacterType;
|
package/UnicodeStringType.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UnicodeStringType = exports.UnicodeString = void 0;
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
class UnicodeString {
|
|
1
|
+
import { Type } from '@mikro-orm/core';
|
|
2
|
+
export class UnicodeString {
|
|
6
3
|
value;
|
|
7
4
|
constructor(value) {
|
|
8
5
|
this.value = value;
|
|
@@ -20,14 +17,13 @@ class UnicodeString {
|
|
|
20
17
|
return this.value;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
class UnicodeStringType extends core_1.Type {
|
|
20
|
+
export class UnicodeStringType extends Type {
|
|
25
21
|
getColumnType(prop, platform) {
|
|
26
22
|
const length = prop.length === -1 ? 'max' : (prop.length ?? this.getDefaultLength(platform));
|
|
27
23
|
return `nvarchar(${length})`;
|
|
28
24
|
}
|
|
29
25
|
convertToJSValue(value) {
|
|
30
|
-
/*
|
|
26
|
+
/* v8 ignore next 3 */
|
|
31
27
|
if (value instanceof UnicodeString) {
|
|
32
28
|
return value.value;
|
|
33
29
|
}
|
|
@@ -49,4 +45,3 @@ class UnicodeStringType extends core_1.Type {
|
|
|
49
45
|
return platform.getDefaultVarcharLength();
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
|
-
exports.UnicodeStringType = UnicodeStringType;
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from '@mikro-orm/knex';
|
|
2
|
-
export * from './MsSqlConnection';
|
|
3
|
-
export * from './MsSqlDriver';
|
|
4
|
-
export * from './MsSqlPlatform';
|
|
5
|
-
export * from './MsSqlSchemaHelper';
|
|
6
|
-
export * from './MsSqlExceptionConverter';
|
|
7
|
-
export * from './UnicodeStringType';
|
|
8
|
-
export { MsSqlMikroORM as MikroORM, MsSqlOptions as Options, defineMsSqlConfig as defineConfig, } from './MsSqlMikroORM';
|
|
2
|
+
export * from './MsSqlConnection.js';
|
|
3
|
+
export * from './MsSqlDriver.js';
|
|
4
|
+
export * from './MsSqlPlatform.js';
|
|
5
|
+
export * from './MsSqlSchemaHelper.js';
|
|
6
|
+
export * from './MsSqlExceptionConverter.js';
|
|
7
|
+
export * from './UnicodeStringType.js';
|
|
8
|
+
export { MsSqlMikroORM as MikroORM, MsSqlOptions as Options, defineMsSqlConfig as defineConfig, } from './MsSqlMikroORM.js';
|
package/index.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.defineConfig = exports.MikroORM = void 0;
|
|
18
|
-
/* istanbul ignore file */
|
|
19
|
-
__exportStar(require("@mikro-orm/knex"), exports);
|
|
20
|
-
__exportStar(require("./MsSqlConnection"), exports);
|
|
21
|
-
__exportStar(require("./MsSqlDriver"), exports);
|
|
22
|
-
__exportStar(require("./MsSqlPlatform"), exports);
|
|
23
|
-
__exportStar(require("./MsSqlSchemaHelper"), exports);
|
|
24
|
-
__exportStar(require("./MsSqlExceptionConverter"), exports);
|
|
25
|
-
__exportStar(require("./UnicodeStringType"), exports);
|
|
26
|
-
var MsSqlMikroORM_1 = require("./MsSqlMikroORM");
|
|
27
|
-
Object.defineProperty(exports, "MikroORM", { enumerable: true, get: function () { return MsSqlMikroORM_1.MsSqlMikroORM; } });
|
|
28
|
-
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return MsSqlMikroORM_1.defineMsSqlConfig; } });
|
|
1
|
+
export * from '@mikro-orm/knex';
|
|
2
|
+
export * from './MsSqlConnection.js';
|
|
3
|
+
export * from './MsSqlDriver.js';
|
|
4
|
+
export * from './MsSqlPlatform.js';
|
|
5
|
+
export * from './MsSqlSchemaHelper.js';
|
|
6
|
+
export * from './MsSqlExceptionConverter.js';
|
|
7
|
+
export * from './UnicodeStringType.js';
|
|
8
|
+
export { MsSqlMikroORM as MikroORM, defineMsSqlConfig as defineConfig, } from './MsSqlMikroORM.js';
|
package/package.json
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mssql",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "7.0.0-dev.2",
|
|
4
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.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"module": "index.mjs",
|
|
7
|
-
"typings": "index.d.ts",
|
|
8
6
|
"exports": {
|
|
9
7
|
"./package.json": "./package.json",
|
|
10
|
-
".":
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./index.d.ts",
|
|
13
|
-
"default": "./index.mjs"
|
|
14
|
-
},
|
|
15
|
-
"require": "./index.js"
|
|
16
|
-
}
|
|
8
|
+
".": "./index.js"
|
|
17
9
|
},
|
|
18
10
|
"repository": {
|
|
19
11
|
"type": "git",
|
|
@@ -49,7 +41,7 @@
|
|
|
49
41
|
"node": ">= 22.11.0"
|
|
50
42
|
},
|
|
51
43
|
"scripts": {
|
|
52
|
-
"build": "yarn clean && yarn compile && yarn copy
|
|
44
|
+
"build": "yarn clean && yarn compile && yarn copy",
|
|
53
45
|
"clean": "yarn run -T rimraf ./dist",
|
|
54
46
|
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
55
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
@@ -58,7 +50,7 @@
|
|
|
58
50
|
"access": "public"
|
|
59
51
|
},
|
|
60
52
|
"dependencies": {
|
|
61
|
-
"@mikro-orm/knex": "7.0.0-dev.
|
|
53
|
+
"@mikro-orm/knex": "7.0.0-dev.2",
|
|
62
54
|
"tarn": "3.0.2",
|
|
63
55
|
"tedious": "19.0.0",
|
|
64
56
|
"tsqlstring": "1.0.1"
|
|
@@ -68,7 +60,7 @@
|
|
|
68
60
|
"kysely": "https://pkg.pr.new/kysely-org/kysely/kysely@2b7007e"
|
|
69
61
|
},
|
|
70
62
|
"peerDependencies": {
|
|
71
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
63
|
+
"@mikro-orm/core": "7.0.0-dev.2",
|
|
72
64
|
"kysely": "*"
|
|
73
65
|
}
|
|
74
66
|
}
|
package/index.mjs
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import mod from "./index.js";
|
|
2
|
-
|
|
3
|
-
export default mod;
|
|
4
|
-
export const ALIAS_REPLACEMENT = mod.ALIAS_REPLACEMENT;
|
|
5
|
-
export const ALIAS_REPLACEMENT_RE = mod.ALIAS_REPLACEMENT_RE;
|
|
6
|
-
export const ARRAY_OPERATORS = mod.ARRAY_OPERATORS;
|
|
7
|
-
export const AbstractNamingStrategy = mod.AbstractNamingStrategy;
|
|
8
|
-
export const AbstractSchemaGenerator = mod.AbstractSchemaGenerator;
|
|
9
|
-
export const AbstractSqlConnection = mod.AbstractSqlConnection;
|
|
10
|
-
export const AbstractSqlDriver = mod.AbstractSqlDriver;
|
|
11
|
-
export const AbstractSqlPlatform = mod.AbstractSqlPlatform;
|
|
12
|
-
export const AfterCreate = mod.AfterCreate;
|
|
13
|
-
export const AfterDelete = mod.AfterDelete;
|
|
14
|
-
export const AfterUpdate = mod.AfterUpdate;
|
|
15
|
-
export const AfterUpsert = mod.AfterUpsert;
|
|
16
|
-
export const ArrayCollection = mod.ArrayCollection;
|
|
17
|
-
export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
|
|
18
|
-
export const ArrayType = mod.ArrayType;
|
|
19
|
-
export const BaseEntity = mod.BaseEntity;
|
|
20
|
-
export const BaseSqliteConnection = mod.BaseSqliteConnection;
|
|
21
|
-
export const BaseSqlitePlatform = mod.BaseSqlitePlatform;
|
|
22
|
-
export const BeforeCreate = mod.BeforeCreate;
|
|
23
|
-
export const BeforeDelete = mod.BeforeDelete;
|
|
24
|
-
export const BeforeUpdate = mod.BeforeUpdate;
|
|
25
|
-
export const BeforeUpsert = mod.BeforeUpsert;
|
|
26
|
-
export const BigIntType = mod.BigIntType;
|
|
27
|
-
export const BlobType = mod.BlobType;
|
|
28
|
-
export const BooleanType = mod.BooleanType;
|
|
29
|
-
export const Cascade = mod.Cascade;
|
|
30
|
-
export const ChangeSet = mod.ChangeSet;
|
|
31
|
-
export const ChangeSetComputer = mod.ChangeSetComputer;
|
|
32
|
-
export const ChangeSetPersister = mod.ChangeSetPersister;
|
|
33
|
-
export const ChangeSetType = mod.ChangeSetType;
|
|
34
|
-
export const CharacterType = mod.CharacterType;
|
|
35
|
-
export const Check = mod.Check;
|
|
36
|
-
export const CheckConstraintViolationException = mod.CheckConstraintViolationException;
|
|
37
|
-
export const Collection = mod.Collection;
|
|
38
|
-
export const CommitOrderCalculator = mod.CommitOrderCalculator;
|
|
39
|
-
export const Config = mod.Config;
|
|
40
|
-
export const Configuration = mod.Configuration;
|
|
41
|
-
export const ConfigurationLoader = mod.ConfigurationLoader;
|
|
42
|
-
export const Connection = mod.Connection;
|
|
43
|
-
export const ConnectionException = mod.ConnectionException;
|
|
44
|
-
export const ConstraintViolationException = mod.ConstraintViolationException;
|
|
45
|
-
export const CreateRequestContext = mod.CreateRequestContext;
|
|
46
|
-
export const CriteriaNode = mod.CriteriaNode;
|
|
47
|
-
export const CriteriaNodeFactory = mod.CriteriaNodeFactory;
|
|
48
|
-
export const Cursor = mod.Cursor;
|
|
49
|
-
export const CursorError = mod.CursorError;
|
|
50
|
-
export const DatabaseDriver = mod.DatabaseDriver;
|
|
51
|
-
export const DatabaseObjectExistsException = mod.DatabaseObjectExistsException;
|
|
52
|
-
export const DatabaseObjectNotFoundException = mod.DatabaseObjectNotFoundException;
|
|
53
|
-
export const DatabaseSchema = mod.DatabaseSchema;
|
|
54
|
-
export const DatabaseTable = mod.DatabaseTable;
|
|
55
|
-
export const DataloaderType = mod.DataloaderType;
|
|
56
|
-
export const DataloaderUtils = mod.DataloaderUtils;
|
|
57
|
-
export const DateTimeType = mod.DateTimeType;
|
|
58
|
-
export const DateType = mod.DateType;
|
|
59
|
-
export const DeadlockException = mod.DeadlockException;
|
|
60
|
-
export const DecimalType = mod.DecimalType;
|
|
61
|
-
export const DefaultLogger = mod.DefaultLogger;
|
|
62
|
-
export const DeferMode = mod.DeferMode;
|
|
63
|
-
export const DoubleType = mod.DoubleType;
|
|
64
|
-
export const DriverException = mod.DriverException;
|
|
65
|
-
export const EagerProps = mod.EagerProps;
|
|
66
|
-
export const Embeddable = mod.Embeddable;
|
|
67
|
-
export const Embedded = mod.Embedded;
|
|
68
|
-
export const EnsureRequestContext = mod.EnsureRequestContext;
|
|
69
|
-
export const Entity = mod.Entity;
|
|
70
|
-
export const EntityAssigner = mod.EntityAssigner;
|
|
71
|
-
export const EntityCaseNamingStrategy = mod.EntityCaseNamingStrategy;
|
|
72
|
-
export const EntityComparator = mod.EntityComparator;
|
|
73
|
-
export const EntityFactory = mod.EntityFactory;
|
|
74
|
-
export const EntityHelper = mod.EntityHelper;
|
|
75
|
-
export const EntityIdentifier = mod.EntityIdentifier;
|
|
76
|
-
export const EntityLoader = mod.EntityLoader;
|
|
77
|
-
export const EntityManager = mod.EntityManager;
|
|
78
|
-
export const EntityManagerType = mod.EntityManagerType;
|
|
79
|
-
export const EntityMetadata = mod.EntityMetadata;
|
|
80
|
-
export const EntityRepository = mod.EntityRepository;
|
|
81
|
-
export const EntityRepositoryType = mod.EntityRepositoryType;
|
|
82
|
-
export const EntitySchema = mod.EntitySchema;
|
|
83
|
-
export const EntitySerializer = mod.EntitySerializer;
|
|
84
|
-
export const EntityTransformer = mod.EntityTransformer;
|
|
85
|
-
export const EntityValidator = mod.EntityValidator;
|
|
86
|
-
export const Enum = mod.Enum;
|
|
87
|
-
export const EnumArrayType = mod.EnumArrayType;
|
|
88
|
-
export const EnumType = mod.EnumType;
|
|
89
|
-
export const EventManager = mod.EventManager;
|
|
90
|
-
export const EventType = mod.EventType;
|
|
91
|
-
export const EventTypeMap = mod.EventTypeMap;
|
|
92
|
-
export const ExceptionConverter = mod.ExceptionConverter;
|
|
93
|
-
export const FileCacheAdapter = mod.FileCacheAdapter;
|
|
94
|
-
export const Filter = mod.Filter;
|
|
95
|
-
export const FloatType = mod.FloatType;
|
|
96
|
-
export const FlushMode = mod.FlushMode;
|
|
97
|
-
export const ForeignKeyConstraintViolationException = mod.ForeignKeyConstraintViolationException;
|
|
98
|
-
export const Formula = mod.Formula;
|
|
99
|
-
export const GeneratedCacheAdapter = mod.GeneratedCacheAdapter;
|
|
100
|
-
export const GroupOperator = mod.GroupOperator;
|
|
101
|
-
export const HiddenProps = mod.HiddenProps;
|
|
102
|
-
export const Hydrator = mod.Hydrator;
|
|
103
|
-
export const IdentityMap = mod.IdentityMap;
|
|
104
|
-
export const Index = mod.Index;
|
|
105
|
-
export const IntegerType = mod.IntegerType;
|
|
106
|
-
export const IntervalType = mod.IntervalType;
|
|
107
|
-
export const InvalidFieldNameException = mod.InvalidFieldNameException;
|
|
108
|
-
export const IsolationLevel = mod.IsolationLevel;
|
|
109
|
-
export const JSON_KEY_OPERATORS = mod.JSON_KEY_OPERATORS;
|
|
110
|
-
export const JoinType = mod.JoinType;
|
|
111
|
-
export const JsonProperty = mod.JsonProperty;
|
|
112
|
-
export const JsonType = mod.JsonType;
|
|
113
|
-
export const Kysely = mod.Kysely;
|
|
114
|
-
export const LoadStrategy = mod.LoadStrategy;
|
|
115
|
-
export const LockMode = mod.LockMode;
|
|
116
|
-
export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
|
|
117
|
-
export const ManyToMany = mod.ManyToMany;
|
|
118
|
-
export const ManyToOne = mod.ManyToOne;
|
|
119
|
-
export const MediumIntType = mod.MediumIntType;
|
|
120
|
-
export const MemoryCacheAdapter = mod.MemoryCacheAdapter;
|
|
121
|
-
export const MetadataDiscovery = mod.MetadataDiscovery;
|
|
122
|
-
export const MetadataError = mod.MetadataError;
|
|
123
|
-
export const MetadataProvider = mod.MetadataProvider;
|
|
124
|
-
export const MetadataStorage = mod.MetadataStorage;
|
|
125
|
-
export const MetadataValidator = mod.MetadataValidator;
|
|
126
|
-
export const MikroORM = mod.MikroORM;
|
|
127
|
-
export const MongoNamingStrategy = mod.MongoNamingStrategy;
|
|
128
|
-
export const MsSqlConnection = mod.MsSqlConnection;
|
|
129
|
-
export const MsSqlDriver = mod.MsSqlDriver;
|
|
130
|
-
export const MsSqlExceptionConverter = mod.MsSqlExceptionConverter;
|
|
131
|
-
export const MsSqlNativeQueryBuilder = mod.MsSqlNativeQueryBuilder;
|
|
132
|
-
export const MsSqlPlatform = mod.MsSqlPlatform;
|
|
133
|
-
export const MsSqlSchemaHelper = mod.MsSqlSchemaHelper;
|
|
134
|
-
export const MySqlExceptionConverter = mod.MySqlExceptionConverter;
|
|
135
|
-
export const MySqlNativeQueryBuilder = mod.MySqlNativeQueryBuilder;
|
|
136
|
-
export const MySqlPlatform = mod.MySqlPlatform;
|
|
137
|
-
export const MySqlSchemaHelper = mod.MySqlSchemaHelper;
|
|
138
|
-
export const NativeQueryBuilder = mod.NativeQueryBuilder;
|
|
139
|
-
export const NodeState = mod.NodeState;
|
|
140
|
-
export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
|
|
141
|
-
export const NotFoundError = mod.NotFoundError;
|
|
142
|
-
export const NotNullConstraintViolationException = mod.NotNullConstraintViolationException;
|
|
143
|
-
export const NullCacheAdapter = mod.NullCacheAdapter;
|
|
144
|
-
export const NullHighlighter = mod.NullHighlighter;
|
|
145
|
-
export const ObjectBindingPattern = mod.ObjectBindingPattern;
|
|
146
|
-
export const ObjectCriteriaNode = mod.ObjectCriteriaNode;
|
|
147
|
-
export const ObjectHydrator = mod.ObjectHydrator;
|
|
148
|
-
export const OnInit = mod.OnInit;
|
|
149
|
-
export const OnLoad = mod.OnLoad;
|
|
150
|
-
export const OneToMany = mod.OneToMany;
|
|
151
|
-
export const OneToOne = mod.OneToOne;
|
|
152
|
-
export const OptimisticLockError = mod.OptimisticLockError;
|
|
153
|
-
export const OptionalProps = mod.OptionalProps;
|
|
154
|
-
export const PlainObject = mod.PlainObject;
|
|
155
|
-
export const Platform = mod.Platform;
|
|
156
|
-
export const PopulateHint = mod.PopulateHint;
|
|
157
|
-
export const PopulatePath = mod.PopulatePath;
|
|
158
|
-
export const PostgreSqlNativeQueryBuilder = mod.PostgreSqlNativeQueryBuilder;
|
|
159
|
-
export const PrimaryKey = mod.PrimaryKey;
|
|
160
|
-
export const PrimaryKeyProp = mod.PrimaryKeyProp;
|
|
161
|
-
export const Property = mod.Property;
|
|
162
|
-
export const QueryBuilder = mod.QueryBuilder;
|
|
163
|
-
export const QueryBuilderHelper = mod.QueryBuilderHelper;
|
|
164
|
-
export const QueryFlag = mod.QueryFlag;
|
|
165
|
-
export const QueryHelper = mod.QueryHelper;
|
|
166
|
-
export const QueryOperator = mod.QueryOperator;
|
|
167
|
-
export const QueryOrder = mod.QueryOrder;
|
|
168
|
-
export const QueryOrderNumeric = mod.QueryOrderNumeric;
|
|
169
|
-
export const QueryType = mod.QueryType;
|
|
170
|
-
export const Raw = mod.Raw;
|
|
171
|
-
export const RawQueryFragment = mod.RawQueryFragment;
|
|
172
|
-
export const ReadOnlyException = mod.ReadOnlyException;
|
|
173
|
-
export const Ref = mod.Ref;
|
|
174
|
-
export const Reference = mod.Reference;
|
|
175
|
-
export const ReferenceKind = mod.ReferenceKind;
|
|
176
|
-
export const ReflectMetadataProvider = mod.ReflectMetadataProvider;
|
|
177
|
-
export const RequestContext = mod.RequestContext;
|
|
178
|
-
export const SCALAR_TYPES = mod.SCALAR_TYPES;
|
|
179
|
-
export const ScalarCriteriaNode = mod.ScalarCriteriaNode;
|
|
180
|
-
export const ScalarReference = mod.ScalarReference;
|
|
181
|
-
export const SchemaComparator = mod.SchemaComparator;
|
|
182
|
-
export const SchemaGenerator = mod.SchemaGenerator;
|
|
183
|
-
export const SchemaHelper = mod.SchemaHelper;
|
|
184
|
-
export const SerializationContext = mod.SerializationContext;
|
|
185
|
-
export const SerializedPrimaryKey = mod.SerializedPrimaryKey;
|
|
186
|
-
export const ServerException = mod.ServerException;
|
|
187
|
-
export const SimpleLogger = mod.SimpleLogger;
|
|
188
|
-
export const SmallIntType = mod.SmallIntType;
|
|
189
|
-
export const SqlEntityManager = mod.SqlEntityManager;
|
|
190
|
-
export const SqlEntityRepository = mod.SqlEntityRepository;
|
|
191
|
-
export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
|
|
192
|
-
export const SqliteExceptionConverter = mod.SqliteExceptionConverter;
|
|
193
|
-
export const SqliteNativeQueryBuilder = mod.SqliteNativeQueryBuilder;
|
|
194
|
-
export const SqliteSchemaHelper = mod.SqliteSchemaHelper;
|
|
195
|
-
export const StringType = mod.StringType;
|
|
196
|
-
export const SyntaxErrorException = mod.SyntaxErrorException;
|
|
197
|
-
export const TableExistsException = mod.TableExistsException;
|
|
198
|
-
export const TableNotFoundException = mod.TableNotFoundException;
|
|
199
|
-
export const TextType = mod.TextType;
|
|
200
|
-
export const TimeType = mod.TimeType;
|
|
201
|
-
export const TinyIntType = mod.TinyIntType;
|
|
202
|
-
export const TransactionContext = mod.TransactionContext;
|
|
203
|
-
export const TransactionEventBroadcaster = mod.TransactionEventBroadcaster;
|
|
204
|
-
export const Transactional = mod.Transactional;
|
|
205
|
-
export const Type = mod.Type;
|
|
206
|
-
export const Uint8ArrayType = mod.Uint8ArrayType;
|
|
207
|
-
export const UnderscoreNamingStrategy = mod.UnderscoreNamingStrategy;
|
|
208
|
-
export const UnicodeString = mod.UnicodeString;
|
|
209
|
-
export const UnicodeStringType = mod.UnicodeStringType;
|
|
210
|
-
export const Unique = mod.Unique;
|
|
211
|
-
export const UniqueConstraintViolationException = mod.UniqueConstraintViolationException;
|
|
212
|
-
export const UnitOfWork = mod.UnitOfWork;
|
|
213
|
-
export const UnknownType = mod.UnknownType;
|
|
214
|
-
export const Utils = mod.Utils;
|
|
215
|
-
export const UuidType = mod.UuidType;
|
|
216
|
-
export const ValidationError = mod.ValidationError;
|
|
217
|
-
export const WrappedEntity = mod.WrappedEntity;
|
|
218
|
-
export const assign = mod.assign;
|
|
219
|
-
export const colors = mod.colors;
|
|
220
|
-
export const compareArrays = mod.compareArrays;
|
|
221
|
-
export const compareBooleans = mod.compareBooleans;
|
|
222
|
-
export const compareBuffers = mod.compareBuffers;
|
|
223
|
-
export const compareObjects = mod.compareObjects;
|
|
224
|
-
export const createSqlFunction = mod.createSqlFunction;
|
|
225
|
-
export const defineConfig = mod.defineConfig;
|
|
226
|
-
export const equals = mod.equals;
|
|
227
|
-
export const getOnConflictFields = mod.getOnConflictFields;
|
|
228
|
-
export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
|
|
229
|
-
export const helper = mod.helper;
|
|
230
|
-
export const isRaw = mod.isRaw;
|
|
231
|
-
export const parseJsonSafe = mod.parseJsonSafe;
|
|
232
|
-
export const raw = mod.raw;
|
|
233
|
-
export const ref = mod.ref;
|
|
234
|
-
export const rel = mod.rel;
|
|
235
|
-
export const serialize = mod.serialize;
|
|
236
|
-
export const sql = mod.sql;
|
|
237
|
-
export const t = mod.t;
|
|
238
|
-
export const types = mod.types;
|
|
239
|
-
export const wrap = mod.wrap;
|