@mikro-orm/mssql 7.0.5-dev.8 → 7.0.5

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.
@@ -3,8 +3,8 @@ import { type ControlledTransaction, MssqlDialect } from 'kysely';
3
3
  import type { ConnectionConfiguration } from 'tedious';
4
4
  /** Microsoft SQL Server database connection using the `tedious` driver. */
5
5
  export declare class MsSqlConnection extends AbstractSqlConnection {
6
- createKyselyDialect(overrides: ConnectionConfiguration): MssqlDialect;
7
- private mapOptions;
8
- commit(ctx: ControlledTransaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
9
- protected transformRawResult<T>(res: any, method: 'all' | 'get' | 'run'): T;
6
+ createKyselyDialect(overrides: ConnectionConfiguration): MssqlDialect;
7
+ private mapOptions;
8
+ commit(ctx: ControlledTransaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
9
+ protected transformRawResult<T>(res: any, method: 'all' | 'get' | 'run'): T;
10
10
  }
@@ -4,77 +4,80 @@ import * as Tedious from 'tedious';
4
4
  import * as Tarn from 'tarn';
5
5
  /** Microsoft SQL Server database connection using the `tedious` driver. */
6
6
  export class MsSqlConnection extends AbstractSqlConnection {
7
- createKyselyDialect(overrides) {
8
- const options = this.mapOptions(overrides);
9
- const poolOptions = Utils.mergeConfig({
10
- min: 0,
11
- max: 10,
12
- }, this.config.get('pool'));
13
- const password = options.authentication?.options?.password;
14
- const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
15
- return new MssqlDialect({
16
- tarn: { ...Tarn, options: poolOptions },
17
- tedious: {
18
- ...Tedious,
19
- connectionFactory: async () => {
20
- options.authentication.options.password = typeof password === 'function' ? await password() : password;
21
- const connection = new Tedious.Connection(options);
22
- /* v8 ignore next */
23
- await onCreateConnection?.(connection);
24
- return connection;
25
- },
26
- },
27
- });
7
+ createKyselyDialect(overrides) {
8
+ const options = this.mapOptions(overrides);
9
+ const poolOptions = Utils.mergeConfig(
10
+ {
11
+ min: 0,
12
+ max: 10,
13
+ },
14
+ this.config.get('pool'),
15
+ );
16
+ const password = options.authentication?.options?.password;
17
+ const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
18
+ return new MssqlDialect({
19
+ tarn: { ...Tarn, options: poolOptions },
20
+ tedious: {
21
+ ...Tedious,
22
+ connectionFactory: async () => {
23
+ options.authentication.options.password = typeof password === 'function' ? await password() : password;
24
+ const connection = new Tedious.Connection(options);
25
+ /* v8 ignore next */
26
+ await onCreateConnection?.(connection);
27
+ return connection;
28
+ },
29
+ },
30
+ });
31
+ }
32
+ mapOptions(overrides) {
33
+ const options = this.getConnectionOptions();
34
+ const ret = {
35
+ authentication: {
36
+ options: {
37
+ password: options.password,
38
+ userName: options.user,
39
+ },
40
+ type: 'default',
41
+ },
42
+ options: {
43
+ database: options.database,
44
+ port: options.port,
45
+ enableArithAbort: true,
46
+ fallbackToDefaultDb: true,
47
+ useUTC: this.config.get('forceUtcTimezone', false),
48
+ encrypt: false,
49
+ },
50
+ server: options.host,
51
+ };
52
+ /* v8 ignore next */
53
+ if (ret.server.includes('\\')) {
54
+ const [host, ...name] = ret.server.split('\\');
55
+ ret.server = host;
56
+ ret.options.instanceName = name.join('\\');
57
+ delete ret.options.port;
28
58
  }
29
- mapOptions(overrides) {
30
- const options = this.getConnectionOptions();
31
- const ret = {
32
- authentication: {
33
- options: {
34
- password: options.password,
35
- userName: options.user,
36
- },
37
- type: 'default',
38
- },
39
- options: {
40
- database: options.database,
41
- port: options.port,
42
- enableArithAbort: true,
43
- fallbackToDefaultDb: true,
44
- useUTC: this.config.get('forceUtcTimezone', false),
45
- encrypt: false,
46
- },
47
- server: options.host,
48
- };
49
- /* v8 ignore next */
50
- if (ret.server.includes('\\')) {
51
- const [host, ...name] = ret.server.split('\\');
52
- ret.server = host;
53
- ret.options.instanceName = name.join('\\');
54
- delete ret.options.port;
55
- }
56
- return Utils.mergeConfig(ret, overrides);
59
+ return Utils.mergeConfig(ret, overrides);
60
+ }
61
+ async commit(ctx, eventBroadcaster) {
62
+ if ('savepointName' in ctx) {
63
+ return;
57
64
  }
58
- async commit(ctx, eventBroadcaster) {
59
- if ('savepointName' in ctx) {
60
- return;
61
- }
62
- return super.commit(ctx, eventBroadcaster);
65
+ return super.commit(ctx, eventBroadcaster);
66
+ }
67
+ transformRawResult(res, method) {
68
+ if (method === 'get') {
69
+ return res.rows[0];
63
70
  }
64
- transformRawResult(res, method) {
65
- if (method === 'get') {
66
- return res.rows[0];
67
- }
68
- if (method === 'all') {
69
- return res.rows;
70
- }
71
- const rowCount = res.rows.length;
72
- const hasEmptyCount = rowCount === 1 && '' in res.rows[0];
73
- const emptyRow = hasEmptyCount && Number(res.rows[0]['']);
74
- return {
75
- affectedRows: hasEmptyCount ? emptyRow : Number(res.numAffectedRows),
76
- row: res.rows[0],
77
- rows: res.rows,
78
- };
71
+ if (method === 'all') {
72
+ return res.rows;
79
73
  }
74
+ const rowCount = res.rows.length;
75
+ const hasEmptyCount = rowCount === 1 && '' in res.rows[0];
76
+ const emptyRow = hasEmptyCount && Number(res.rows[0]['']);
77
+ return {
78
+ affectedRows: hasEmptyCount ? emptyRow : Number(res.numAffectedRows),
79
+ row: res.rows[0],
80
+ rows: res.rows,
81
+ };
82
+ }
80
83
  }
package/MsSqlDriver.d.ts CHANGED
@@ -1,14 +1,37 @@
1
- import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type EntityName, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction, type Constructor } from '@mikro-orm/core';
1
+ import {
2
+ type AnyEntity,
3
+ type Configuration,
4
+ type ConnectionType,
5
+ type EntityDictionary,
6
+ type EntityName,
7
+ type LoggingOptions,
8
+ type NativeInsertUpdateManyOptions,
9
+ type QueryResult,
10
+ type Transaction,
11
+ type Constructor,
12
+ } from '@mikro-orm/core';
2
13
  import { AbstractSqlDriver, type SqlEntityManager } from '@mikro-orm/sql';
3
14
  import { MsSqlConnection } from './MsSqlConnection.js';
4
15
  import { MsSqlQueryBuilder } from './MsSqlQueryBuilder.js';
5
16
  import { MsSqlMikroORM } from './MsSqlMikroORM.js';
6
17
  /** Database driver for Microsoft SQL Server. */
7
18
  export declare class MsSqlDriver extends AbstractSqlDriver<MsSqlConnection> {
8
- constructor(config: Configuration);
9
- nativeInsertMany<T extends AnyEntity<T>>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
10
- createQueryBuilder<T extends AnyEntity<T>>(entityName: EntityName<T>, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): MsSqlQueryBuilder<T, any, any, any>;
11
- private appendOutputTable;
12
- /** @inheritDoc */
13
- getORMClass(): Constructor<MsSqlMikroORM>;
19
+ constructor(config: Configuration);
20
+ nativeInsertMany<T extends AnyEntity<T>>(
21
+ entityName: EntityName<T>,
22
+ data: EntityDictionary<T>[],
23
+ options?: NativeInsertUpdateManyOptions<T>,
24
+ ): Promise<QueryResult<T>>;
25
+ createQueryBuilder<T extends AnyEntity<T>>(
26
+ entityName: EntityName<T>,
27
+ ctx?: Transaction,
28
+ preferredConnectionType?: ConnectionType,
29
+ convertCustomTypes?: boolean,
30
+ loggerContext?: LoggingOptions,
31
+ alias?: string,
32
+ em?: SqlEntityManager,
33
+ ): MsSqlQueryBuilder<T, any, any, any>;
34
+ private appendOutputTable;
35
+ /** @inheritDoc */
36
+ getORMClass(): Constructor<MsSqlMikroORM>;
14
37
  }
package/MsSqlDriver.js CHANGED
@@ -1,4 +1,4 @@
1
- import { QueryFlag, Utils, isRaw, } from '@mikro-orm/core';
1
+ import { QueryFlag, Utils, isRaw } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver } from '@mikro-orm/sql';
3
3
  import { MsSqlConnection } from './MsSqlConnection.js';
4
4
  import { MsSqlPlatform } from './MsSqlPlatform.js';
@@ -6,78 +6,81 @@ import { MsSqlQueryBuilder } from './MsSqlQueryBuilder.js';
6
6
  import { MsSqlMikroORM } from './MsSqlMikroORM.js';
7
7
  /** Database driver for Microsoft SQL Server. */
8
8
  export class MsSqlDriver extends AbstractSqlDriver {
9
- constructor(config) {
10
- super(config, new MsSqlPlatform(), MsSqlConnection, ['kysely', 'tedious']);
9
+ constructor(config) {
10
+ super(config, new MsSqlPlatform(), MsSqlConnection, ['kysely', 'tedious']);
11
+ }
12
+ async nativeInsertMany(entityName, data, options = {}) {
13
+ const meta = this.metadata.get(entityName);
14
+ const keys = new Set();
15
+ data.forEach(row => Object.keys(row).forEach(k => keys.add(k)));
16
+ const props = [...keys].map(name => meta.properties[name] ?? { name, fieldNames: [name] });
17
+ const fields = Utils.flatten(props.map(prop => prop.fieldNames));
18
+ const tableName = this.getTableName(meta, options);
19
+ const hasFields = fields.length > 0;
20
+ // Is this en empty insert... this is rather hard in mssql (especially with an insert many)
21
+ if (!hasFields) {
22
+ const returningProps = meta.props.filter(prop => prop.primary || prop.defaultRaw);
23
+ const returningFields = Utils.flatten(returningProps.map(prop => prop.fieldNames));
24
+ const using2 = `select * from (values ${data.map((x, i) => `(${i})`).join(',')}) v (id) where 1 = 1`;
25
+ /* v8 ignore next */
26
+ const output =
27
+ returningFields.length > 0
28
+ ? `output ${returningFields.map(field => 'inserted.' + this.platform.quoteIdentifier(field)).join(', ')}`
29
+ : '';
30
+ const sql = `merge into ${tableName} using (${using2}) s on 1 = 0 when not matched then insert default values ${output};`;
31
+ const res = await this.execute(sql, [], 'run', options.ctx);
32
+ const pks = this.getPrimaryKeyFields(meta);
33
+ if (pks.length === 1) {
34
+ res.row ??= {};
35
+ res.rows ??= [];
36
+ res.insertId = res.insertId || res.row[pks[0]];
37
+ }
38
+ return res;
11
39
  }
12
- async nativeInsertMany(entityName, data, options = {}) {
13
- const meta = this.metadata.get(entityName);
14
- const keys = new Set();
15
- data.forEach(row => Object.keys(row).forEach(k => keys.add(k)));
16
- const props = [...keys].map(name => meta.properties[name] ?? { name, fieldNames: [name] });
17
- const fields = Utils.flatten(props.map(prop => prop.fieldNames));
18
- const tableName = this.getTableName(meta, options);
19
- const hasFields = fields.length > 0;
20
- // Is this en empty insert... this is rather hard in mssql (especially with an insert many)
21
- if (!hasFields) {
22
- const returningProps = meta.props.filter(prop => prop.primary || prop.defaultRaw);
23
- const returningFields = Utils.flatten(returningProps.map(prop => prop.fieldNames));
24
- const using2 = `select * from (values ${data.map((x, i) => `(${i})`).join(',')}) v (id) where 1 = 1`;
25
- /* v8 ignore next */
26
- const output = returningFields.length > 0
27
- ? `output ${returningFields.map(field => 'inserted.' + this.platform.quoteIdentifier(field)).join(', ')}`
28
- : '';
29
- const sql = `merge into ${tableName} using (${using2}) s on 1 = 0 when not matched then insert default values ${output};`;
30
- const res = await this.execute(sql, [], 'run', options.ctx);
31
- const pks = this.getPrimaryKeyFields(meta);
32
- if (pks.length === 1) {
33
- res.row ??= {};
34
- res.rows ??= [];
35
- res.insertId = res.insertId || res.row[pks[0]];
36
- }
37
- return res;
38
- }
39
- // For TPT child entities, the parent table owns the identity column, not the child table
40
- if (props.some(prop => prop.autoincrement && (!meta.ownProps || meta.ownProps.includes(prop)))) {
41
- return super.nativeInsertMany(entityName, data, options, sql => {
42
- return `set identity_insert ${tableName} on; ${sql}; set identity_insert ${tableName} off`;
43
- });
44
- }
45
- return super.nativeInsertMany(entityName, data, options, sql => meta.hasTriggers ? this.appendOutputTable(entityName, data, sql) : sql);
40
+ // For TPT child entities, the parent table owns the identity column, not the child table
41
+ if (props.some(prop => prop.autoincrement && (!meta.ownProps || meta.ownProps.includes(prop)))) {
42
+ return super.nativeInsertMany(entityName, data, options, sql => {
43
+ return `set identity_insert ${tableName} on; ${sql}; set identity_insert ${tableName} off`;
44
+ });
46
45
  }
47
- createQueryBuilder(entityName, ctx, preferredConnectionType, convertCustomTypes, loggerContext, alias, em) {
48
- // do not compute the connectionType if EM is provided as it will be computed from it in the QB later on
49
- const connectionType = em
50
- ? preferredConnectionType
51
- : this.resolveConnectionType({ ctx, connectionType: preferredConnectionType });
52
- const qb = new MsSqlQueryBuilder(entityName, this.metadata, this, ctx, alias, connectionType, em, loggerContext);
53
- if (!convertCustomTypes) {
54
- qb.unsetFlag(QueryFlag.CONVERT_CUSTOM_TYPES);
55
- }
56
- return qb;
46
+ return super.nativeInsertMany(entityName, data, options, sql =>
47
+ meta.hasTriggers ? this.appendOutputTable(entityName, data, sql) : sql,
48
+ );
49
+ }
50
+ createQueryBuilder(entityName, ctx, preferredConnectionType, convertCustomTypes, loggerContext, alias, em) {
51
+ // do not compute the connectionType if EM is provided as it will be computed from it in the QB later on
52
+ const connectionType = em
53
+ ? preferredConnectionType
54
+ : this.resolveConnectionType({ ctx, connectionType: preferredConnectionType });
55
+ const qb = new MsSqlQueryBuilder(entityName, this.metadata, this, ctx, alias, connectionType, em, loggerContext);
56
+ if (!convertCustomTypes) {
57
+ qb.unsetFlag(QueryFlag.CONVERT_CUSTOM_TYPES);
57
58
  }
58
- appendOutputTable(entityName, data, sql) {
59
- const meta = this.metadata.get(entityName);
60
- const returningProps = meta.props
61
- .filter(prop => (prop.persist !== false && prop.defaultRaw) || prop.autoincrement || prop.generated)
62
- .filter(prop => !(prop.name in data[0]) || isRaw(data[0][prop.name]));
63
- const returningFields = Utils.flatten(returningProps.map(prop => prop.fieldNames));
64
- /* v8 ignore next */
65
- if (returningFields.length === 0) {
66
- return sql;
67
- }
68
- const tableName = this.getTableName(meta, {}, true);
69
- const selections = returningFields.map((field) => `[t].${this.platform.quoteIdentifier(field)}`).join(',');
70
- const position = sql.indexOf(' values ');
71
- const sqlBeforeValues = sql.substring(0, position);
72
- const sqlAfterValues = sql.substring(position + 1);
73
- let outputSql = `select top(0) ${selections} into #out from ${tableName} as t left join ${tableName} on 0 = 1; `;
74
- outputSql += `${sqlBeforeValues} into #out ${sqlAfterValues}; `;
75
- outputSql += `select ${selections} from #out as t; `;
76
- outputSql += `drop table #out`;
77
- return outputSql;
78
- }
79
- /** @inheritDoc */
80
- getORMClass() {
81
- return MsSqlMikroORM;
59
+ return qb;
60
+ }
61
+ appendOutputTable(entityName, data, sql) {
62
+ const meta = this.metadata.get(entityName);
63
+ const returningProps = meta.props
64
+ .filter(prop => (prop.persist !== false && prop.defaultRaw) || prop.autoincrement || prop.generated)
65
+ .filter(prop => !(prop.name in data[0]) || isRaw(data[0][prop.name]));
66
+ const returningFields = Utils.flatten(returningProps.map(prop => prop.fieldNames));
67
+ /* v8 ignore next */
68
+ if (returningFields.length === 0) {
69
+ return sql;
82
70
  }
71
+ const tableName = this.getTableName(meta, {}, true);
72
+ const selections = returningFields.map(field => `[t].${this.platform.quoteIdentifier(field)}`).join(',');
73
+ const position = sql.indexOf(' values ');
74
+ const sqlBeforeValues = sql.substring(0, position);
75
+ const sqlAfterValues = sql.substring(position + 1);
76
+ let outputSql = `select top(0) ${selections} into #out from ${tableName} as t left join ${tableName} on 0 = 1; `;
77
+ outputSql += `${sqlBeforeValues} into #out ${sqlAfterValues}; `;
78
+ outputSql += `select ${selections} from #out as t; `;
79
+ outputSql += `drop table #out`;
80
+ return outputSql;
81
+ }
82
+ /** @inheritDoc */
83
+ getORMClass() {
84
+ return MsSqlMikroORM;
85
+ }
83
86
  }
@@ -1,9 +1,9 @@
1
1
  import { ExceptionConverter, type Dictionary, type DriverException } from '@mikro-orm/core';
2
2
  /** Converts MSSQL native errors into typed MikroORM driver exceptions. */
3
3
  export declare class MsSqlExceptionConverter extends ExceptionConverter {
4
- /**
5
- * @see https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-511-database-engine-error?view=sql-server-ver15
6
- * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
7
- */
8
- convertException(exception: Error & Dictionary): DriverException;
4
+ /**
5
+ * @see https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-511-database-engine-error?view=sql-server-ver15
6
+ * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
7
+ */
8
+ convertException(exception: Error & Dictionary): DriverException;
9
9
  }
@@ -1,37 +1,48 @@
1
- import { ExceptionConverter, InvalidFieldNameException, NonUniqueFieldNameException, NotNullConstraintViolationException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, } from '@mikro-orm/core';
1
+ import {
2
+ ExceptionConverter,
3
+ InvalidFieldNameException,
4
+ NonUniqueFieldNameException,
5
+ NotNullConstraintViolationException,
6
+ SyntaxErrorException,
7
+ TableExistsException,
8
+ TableNotFoundException,
9
+ UniqueConstraintViolationException,
10
+ } from '@mikro-orm/core';
2
11
  /** Converts MSSQL native errors into typed MikroORM driver exceptions. */
3
12
  export class MsSqlExceptionConverter extends ExceptionConverter {
4
- /**
5
- * @see https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-511-database-engine-error?view=sql-server-ver15
6
- * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
7
- */
8
- convertException(exception) {
9
- let errno = exception.number;
10
- /* v8 ignore next */
11
- if ('errors' in exception &&
12
- Array.isArray(exception.errors) &&
13
- typeof exception.errors[0] === 'object' &&
14
- 'message' in exception.errors[0]) {
15
- exception.message += '\n' + exception.errors.map(e => e.message).join('\n');
16
- errno ??= exception.errors[0].number;
17
- exception.lineNumber ??= exception.errors[0].lineNumber;
18
- }
19
- switch (errno) {
20
- case 515:
21
- return new NotNullConstraintViolationException(exception);
22
- case 102:
23
- return new SyntaxErrorException(exception);
24
- case 207:
25
- return new InvalidFieldNameException(exception);
26
- case 208:
27
- return new TableNotFoundException(exception);
28
- case 209:
29
- return new NonUniqueFieldNameException(exception);
30
- case 2601:
31
- return new UniqueConstraintViolationException(exception);
32
- case 2714:
33
- return new TableExistsException(exception);
34
- }
35
- return super.convertException(exception);
13
+ /**
14
+ * @see https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-511-database-engine-error?view=sql-server-ver15
15
+ * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
16
+ */
17
+ convertException(exception) {
18
+ let errno = exception.number;
19
+ /* v8 ignore next */
20
+ if (
21
+ 'errors' in exception &&
22
+ Array.isArray(exception.errors) &&
23
+ typeof exception.errors[0] === 'object' &&
24
+ 'message' in exception.errors[0]
25
+ ) {
26
+ exception.message += '\n' + exception.errors.map(e => e.message).join('\n');
27
+ errno ??= exception.errors[0].number;
28
+ exception.lineNumber ??= exception.errors[0].lineNumber;
36
29
  }
30
+ switch (errno) {
31
+ case 515:
32
+ return new NotNullConstraintViolationException(exception);
33
+ case 102:
34
+ return new SyntaxErrorException(exception);
35
+ case 207:
36
+ return new InvalidFieldNameException(exception);
37
+ case 208:
38
+ return new TableNotFoundException(exception);
39
+ case 209:
40
+ return new NonUniqueFieldNameException(exception);
41
+ case 2601:
42
+ return new UniqueConstraintViolationException(exception);
43
+ case 2714:
44
+ return new TableExistsException(exception);
45
+ }
46
+ return super.convertException(exception);
47
+ }
37
48
  }
@@ -1,20 +1,58 @@
1
- import { type AnyEntity, type EntityClass, type EntitySchema, MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
1
+ import {
2
+ type AnyEntity,
3
+ type EntityClass,
4
+ type EntitySchema,
5
+ MikroORM,
6
+ type Options,
7
+ type IDatabaseDriver,
8
+ type EntityManager,
9
+ type EntityManagerType,
10
+ } from '@mikro-orm/core';
2
11
  import type { SqlEntityManager } from '@mikro-orm/sql';
3
12
  import { MsSqlDriver } from './MsSqlDriver.js';
4
13
  /** Configuration options for the MSSQL driver. */
5
- export type MsSqlOptions<EM extends SqlEntityManager<MsSqlDriver> = SqlEntityManager<MsSqlDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Partial<Options<MsSqlDriver, EM, Entities>>;
14
+ export type MsSqlOptions<
15
+ EM extends SqlEntityManager<MsSqlDriver> = SqlEntityManager<MsSqlDriver>,
16
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
17
+ | string
18
+ | EntityClass<AnyEntity>
19
+ | EntitySchema
20
+ )[],
21
+ > = Partial<Options<MsSqlDriver, EM, Entities>>;
6
22
  /** Creates a type-safe configuration object for the MSSQL driver. */
7
- export declare function defineMsSqlConfig<EM extends SqlEntityManager<MsSqlDriver> = SqlEntityManager<MsSqlDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<MsSqlDriver, EM, Entities>>): Partial<Options<MsSqlDriver, EM, Entities>>;
23
+ export declare function defineMsSqlConfig<
24
+ EM extends SqlEntityManager<MsSqlDriver> = SqlEntityManager<MsSqlDriver>,
25
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
26
+ | string
27
+ | EntityClass<AnyEntity>
28
+ | EntitySchema
29
+ )[],
30
+ >(options: Partial<Options<MsSqlDriver, EM, Entities>>): Partial<Options<MsSqlDriver, EM, Entities>>;
8
31
  /**
9
32
  * @inheritDoc
10
33
  */
11
- export declare class MsSqlMikroORM<EM extends SqlEntityManager<MsSqlDriver> = SqlEntityManager<MsSqlDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<MsSqlDriver, EM, Entities> {
12
- /**
13
- * @inheritDoc
14
- */
15
- static init<D extends IDatabaseDriver = MsSqlDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
16
- /**
17
- * @inheritDoc
18
- */
19
- constructor(options: Partial<Options<MsSqlDriver, EM, Entities>>);
34
+ export declare class MsSqlMikroORM<
35
+ EM extends SqlEntityManager<MsSqlDriver> = SqlEntityManager<MsSqlDriver>,
36
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
37
+ | string
38
+ | EntityClass<AnyEntity>
39
+ | EntitySchema
40
+ )[],
41
+ > extends MikroORM<MsSqlDriver, EM, Entities> {
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ static init<
46
+ D extends IDatabaseDriver = MsSqlDriver,
47
+ EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>,
48
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
49
+ | string
50
+ | EntityClass<AnyEntity>
51
+ | EntitySchema
52
+ )[],
53
+ >(options: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ constructor(options: Partial<Options<MsSqlDriver, EM, Entities>>);
20
58
  }
package/MsSqlMikroORM.js CHANGED
@@ -1,23 +1,23 @@
1
- import { defineConfig, MikroORM, } from '@mikro-orm/core';
1
+ import { defineConfig, MikroORM } from '@mikro-orm/core';
2
2
  import { MsSqlDriver } from './MsSqlDriver.js';
3
3
  /** Creates a type-safe configuration object for the MSSQL driver. */
4
4
  export function defineMsSqlConfig(options) {
5
- return defineConfig({ driver: MsSqlDriver, ...options });
5
+ return defineConfig({ driver: MsSqlDriver, ...options });
6
6
  }
7
7
  /**
8
8
  * @inheritDoc
9
9
  */
10
10
  export class MsSqlMikroORM extends MikroORM {
11
- /**
12
- * @inheritDoc
13
- */
14
- static async init(options) {
15
- return super.init(defineMsSqlConfig(options));
16
- }
17
- /**
18
- * @inheritDoc
19
- */
20
- constructor(options) {
21
- super(defineMsSqlConfig(options));
22
- }
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ static async init(options) {
15
+ return super.init(defineMsSqlConfig(options));
16
+ }
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ constructor(options) {
21
+ super(defineMsSqlConfig(options));
22
+ }
23
23
  }