@mikro-orm/mssql 6.4.7-dev.1 → 7.0.0-dev.1

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.
@@ -1,14 +1,9 @@
1
- import { AbstractSqlConnection, type IsolationLevel, type Knex, type TransactionEventBroadcaster } from '@mikro-orm/knex';
1
+ import { AbstractSqlConnection, type TransactionEventBroadcaster } from '@mikro-orm/knex';
2
+ import { type ControlledTransaction, MssqlDialect } from 'kysely';
3
+ import type { ConnectionConfiguration } from 'tedious';
2
4
  export declare class MsSqlConnection extends AbstractSqlConnection {
3
- createKnex(): void;
4
- getDefaultClientUrl(): string;
5
- getConnectionOptions(): Knex.MsSqlConnectionConfig;
6
- begin(options?: {
7
- isolationLevel?: IsolationLevel;
8
- ctx?: Knex.Transaction;
9
- eventBroadcaster?: TransactionEventBroadcaster;
10
- }): Promise<Knex.Transaction>;
11
- commit(ctx: Knex.Transaction, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
12
- rollback(ctx: Knex.Transaction, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
5
+ createKyselyDialect(overrides: ConnectionConfiguration): MssqlDialect;
6
+ private mapOptions;
7
+ commit(ctx: ControlledTransaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster): Promise<void>;
13
8
  protected transformRawResult<T>(res: any, method: 'all' | 'get' | 'run'): T;
14
9
  }
@@ -1,69 +1,114 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.MsSqlConnection = void 0;
4
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"));
5
41
  class MsSqlConnection extends knex_1.AbstractSqlConnection {
6
- createKnex() {
7
- this.client = this.createKnexClient(knex_1.MsSqlKnexDialect);
8
- this.connected = true;
9
- }
10
- getDefaultClientUrl() {
11
- return 'mssql://sa@localhost:1433';
42
+ createKyselyDialect(overrides) {
43
+ const options = this.mapOptions(overrides);
44
+ const poolOptions = knex_1.Utils.mergeConfig({
45
+ min: 0,
46
+ max: 10,
47
+ }, this.config.get('pool'));
48
+ const password = options.authentication?.options?.password;
49
+ const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
50
+ return new kysely_1.MssqlDialect({
51
+ tarn: { ...Tarn, options: poolOptions },
52
+ tedious: {
53
+ ...Tedious,
54
+ connectionFactory: async () => {
55
+ options.authentication.options.password = typeof password === 'function' ? await password() : password;
56
+ const connection = new Tedious.Connection(options);
57
+ await onCreateConnection?.(connection);
58
+ return connection;
59
+ },
60
+ },
61
+ });
12
62
  }
13
- getConnectionOptions() {
14
- const config = super.getConnectionOptions();
15
- const overrides = {
63
+ mapOptions(overrides) {
64
+ const options = this.getConnectionOptions();
65
+ const ret = {
66
+ authentication: {
67
+ options: {
68
+ password: options.password,
69
+ userName: options.user,
70
+ },
71
+ type: 'default',
72
+ },
16
73
  options: {
74
+ database: options.database,
75
+ port: options.port,
17
76
  enableArithAbort: true,
18
77
  fallbackToDefaultDb: true,
19
78
  useUTC: this.config.get('forceUtcTimezone', false),
79
+ encrypt: false,
20
80
  },
81
+ server: options.host,
21
82
  };
22
83
  /* istanbul ignore next */
23
- if (config.host?.includes('\\')) {
24
- const [host, ...name] = config.host.split('\\');
25
- overrides.server = host;
26
- overrides.options.instanceName = name.join('\\');
27
- delete config.host;
28
- delete config.port;
84
+ if (ret.server.includes('\\')) {
85
+ const [host, ...name] = ret.server.split('\\');
86
+ ret.server = host;
87
+ ret.options.instanceName = name.join('\\');
88
+ delete ret.options.port;
29
89
  }
30
- knex_1.Utils.mergeConfig(config, overrides);
31
- return config;
32
- }
33
- async begin(options = {}) {
34
- if (!options.ctx) {
35
- if (options.isolationLevel) {
36
- this.logQuery(`set transaction isolation level ${options.isolationLevel}`);
37
- }
38
- this.logQuery('begin');
39
- }
40
- return super.begin(options);
90
+ return knex_1.Utils.mergeConfig(ret, overrides);
41
91
  }
42
92
  async commit(ctx, eventBroadcaster) {
43
- this.logQuery('commit');
44
- return super.commit(ctx, eventBroadcaster);
45
- }
46
- async rollback(ctx, eventBroadcaster) {
47
- if (eventBroadcaster?.isTopLevel()) {
48
- this.logQuery('rollback');
93
+ if ('savepointName' in ctx) {
94
+ return;
49
95
  }
50
- return super.rollback(ctx, eventBroadcaster);
96
+ return super.commit(ctx, eventBroadcaster);
51
97
  }
52
98
  transformRawResult(res, method) {
53
99
  if (method === 'get') {
54
- return res[0];
100
+ return res.rows[0];
55
101
  }
56
- if (method === 'all' || !res) {
57
- return res;
102
+ if (method === 'all') {
103
+ return res.rows;
58
104
  }
59
- const rowCount = res.length;
60
- const hasEmptyCount = (rowCount === 1) && ('' in res[0]);
61
- const emptyRow = hasEmptyCount && res[0][''];
105
+ const rowCount = res.rows.length;
106
+ const hasEmptyCount = (rowCount === 1) && ('' in res.rows[0]);
107
+ const emptyRow = hasEmptyCount && Number(res.rows[0]['']);
62
108
  return {
63
- affectedRows: hasEmptyCount ? emptyRow : res.length,
64
- insertId: res[0] ? res[0].id : 0,
65
- row: res[0],
66
- rows: res,
109
+ affectedRows: hasEmptyCount ? emptyRow : Number(res.numAffectedRows),
110
+ row: res.rows[0],
111
+ rows: res.rows,
67
112
  };
68
113
  }
69
114
  }
package/MsSqlDriver.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction } from '@mikro-orm/core';
2
- import { AbstractSqlDriver, type Knex, type SqlEntityManager } from '@mikro-orm/knex';
2
+ import { AbstractSqlDriver, type SqlEntityManager } from '@mikro-orm/knex';
3
3
  import { MsSqlConnection } from './MsSqlConnection';
4
4
  import { MsSqlQueryBuilder } from './MsSqlQueryBuilder';
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>>;
8
- createQueryBuilder<T extends AnyEntity<T>>(entityName: string, ctx?: Transaction<Knex.Transaction>, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): MsSqlQueryBuilder<T, any, any, any>;
8
+ createQueryBuilder<T extends AnyEntity<T>>(entityName: string, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): MsSqlQueryBuilder<T, any, any, any>;
9
9
  }
package/MsSqlDriver.js CHANGED
@@ -8,7 +8,7 @@ const MsSqlPlatform_1 = require("./MsSqlPlatform");
8
8
  const MsSqlQueryBuilder_1 = require("./MsSqlQueryBuilder");
9
9
  class MsSqlDriver extends knex_1.AbstractSqlDriver {
10
10
  constructor(config) {
11
- super(config, new MsSqlPlatform_1.MsSqlPlatform(), MsSqlConnection_1.MsSqlConnection, ['knex', 'tedious']);
11
+ super(config, new MsSqlPlatform_1.MsSqlPlatform(), MsSqlConnection_1.MsSqlConnection, ['kysely', 'tedious']);
12
12
  }
13
13
  async nativeInsertMany(entityName, data, options = {}) {
14
14
  const meta = this.metadata.get(entityName);
@@ -1,4 +1,4 @@
1
- import { AbstractSqlPlatform, type EntityMetadata, type IDatabaseDriver, type EntityManager, type MikroORM, Type, type Primary, type IPrimaryKey } from '@mikro-orm/knex';
1
+ import { AbstractSqlPlatform, type EntityMetadata, type IDatabaseDriver, type EntityManager, type MikroORM, Type, type Primary, type IPrimaryKey, MsSqlNativeQueryBuilder } from '@mikro-orm/knex';
2
2
  import { MsSqlSchemaHelper } from './MsSqlSchemaHelper';
3
3
  import { MsSqlExceptionConverter } from './MsSqlExceptionConverter';
4
4
  import { MsSqlSchemaGenerator } from './MsSqlSchemaGenerator';
@@ -9,6 +9,10 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
9
9
  lookupExtensions(orm: MikroORM): void;
10
10
  /** @inheritDoc */
11
11
  init(orm: MikroORM): void;
12
+ getRollbackToSavepointSQL(savepointName: string): string;
13
+ getSavepointSQL(savepointName: string): string;
14
+ /** @internal */
15
+ createNativeQueryBuilder(): MsSqlNativeQueryBuilder;
12
16
  usesOutputStatement(): boolean;
13
17
  convertDateToJSValue(value: string | Date): string;
14
18
  convertsJsonAutomatically(): boolean;
@@ -35,7 +39,7 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
35
39
  unsigned?: boolean;
36
40
  autoincrement?: boolean;
37
41
  }): string;
38
- normalizeColumnType(type: string, options?: {
42
+ normalizeColumnType(type: string, options: {
39
43
  length?: number;
40
44
  precision?: number;
41
45
  scale?: number;
@@ -48,10 +52,12 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
48
52
  validateMetadata(meta: EntityMetadata): void;
49
53
  getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string;
50
54
  normalizePrimaryKey<T extends number | string = number | string>(data: Primary<T> | IPrimaryKey | string): T;
55
+ usesEnumCheckConstraints(): boolean;
51
56
  supportsMultipleCascadePaths(): boolean;
52
57
  supportsMultipleStatements(): boolean;
53
58
  quoteIdentifier(id: string): string;
54
59
  escape(value: any): string;
55
60
  getSchemaGenerator(driver: IDatabaseDriver, em?: EntityManager): MsSqlSchemaGenerator;
56
61
  allowsComparingTuples(): boolean;
62
+ getDefaultClientUrl(): string;
57
63
  }
package/MsSqlPlatform.js CHANGED
@@ -23,7 +23,17 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
23
23
  init(orm) {
24
24
  super.init(orm);
25
25
  // do not double escape backslash inside strings
26
- tsqlstring_1.default.CHARS_GLOBAL_REGEXP = /[']/g;
26
+ tsqlstring_1.default.CHARS_GLOBAL_REGEXP = /'/g;
27
+ }
28
+ getRollbackToSavepointSQL(savepointName) {
29
+ return `rollback transaction ${this.quoteIdentifier(savepointName)}`;
30
+ }
31
+ getSavepointSQL(savepointName) {
32
+ return `save transaction ${this.quoteIdentifier(savepointName)}`;
33
+ }
34
+ /** @internal */
35
+ createNativeQueryBuilder() {
36
+ return new knex_1.MsSqlNativeQueryBuilder(this);
27
37
  }
28
38
  usesOutputStatement() {
29
39
  return true;
@@ -85,7 +95,7 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
85
95
  /* istanbul ignore next */
86
96
  return this.getSmallIntTypeDeclarationSQL(column);
87
97
  }
88
- normalizeColumnType(type, options = {}) {
98
+ normalizeColumnType(type, options) {
89
99
  const simpleType = this.extractSimpleType(type);
90
100
  if (['decimal', 'numeric'].includes(simpleType)) {
91
101
  return this.getDecimalTypeDeclarationSQL(options);
@@ -158,6 +168,9 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
158
168
  }
159
169
  return data;
160
170
  }
171
+ usesEnumCheckConstraints() {
172
+ return true;
173
+ }
161
174
  supportsMultipleCascadePaths() {
162
175
  return false;
163
176
  }
@@ -165,6 +178,9 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
165
178
  return true;
166
179
  }
167
180
  quoteIdentifier(id) {
181
+ if (knex_1.RawQueryFragment.isKnownFragment(id)) {
182
+ return super.quoteIdentifier(id);
183
+ }
168
184
  return `[${id.replace('.', `].[`)}]`;
169
185
  }
170
186
  escape(value) {
@@ -186,5 +202,8 @@ class MsSqlPlatform extends knex_1.AbstractSqlPlatform {
186
202
  allowsComparingTuples() {
187
203
  return false;
188
204
  }
205
+ getDefaultClientUrl() {
206
+ return 'mssql://sa@localhost:1433';
207
+ }
189
208
  }
190
209
  exports.MsSqlPlatform = MsSqlPlatform;
@@ -1,9 +1,6 @@
1
1
  import { type AnyEntity, type RequiredEntityData } from '@mikro-orm/core';
2
- import { type InsertQueryBuilder, type Knex, QueryBuilder } from '@mikro-orm/knex';
2
+ import { type InsertQueryBuilder, QueryBuilder } from '@mikro-orm/knex';
3
3
  export declare class MsSqlQueryBuilder<Entity extends object = AnyEntity, RootAlias extends string = never, Hint extends string = never, Context extends object = never> extends QueryBuilder<Entity, RootAlias, Hint, Context> {
4
4
  insert(data: RequiredEntityData<Entity> | RequiredEntityData<Entity>[]): InsertQueryBuilder<Entity>;
5
- getKnex(): Knex.QueryBuilder;
6
- getKnexQuery(processVirtualEntity?: boolean): Knex.QueryBuilder;
7
- private appendIdentityInsert;
8
5
  private checkIdentityInsert;
9
6
  }
@@ -8,36 +8,6 @@ class MsSqlQueryBuilder extends knex_1.QueryBuilder {
8
8
  this.checkIdentityInsert(data);
9
9
  return super.insert(data);
10
10
  }
11
- getKnex() {
12
- const qb = super.getKnex();
13
- if (this.flags.has(core_1.QueryFlag.IDENTITY_INSERT)) {
14
- this.appendIdentityInsert(qb);
15
- }
16
- return qb;
17
- }
18
- getKnexQuery(processVirtualEntity = true) {
19
- if (this.type === knex_1.QueryType.TRUNCATE) {
20
- const tableName = this.driver.getTableName(this.mainAlias.metadata, { schema: this._schema }, false);
21
- const tableNameQuoted = this.platform.quoteIdentifier(tableName);
22
- const sql = `delete from ${tableNameQuoted}; declare @count int = case @@rowcount when 0 then 1 else 0 end; dbcc checkident ('${tableName}', reseed, @count)`;
23
- this._query = {};
24
- return this._query.qb = this.knex.raw(sql);
25
- }
26
- return super.getKnexQuery(processVirtualEntity);
27
- }
28
- appendIdentityInsert(qb) {
29
- const meta = this.metadata.get(this.mainAlias.entityName);
30
- const table = this.driver.getTableName(meta, { schema: this._schema });
31
- const originalToSQL = qb.toSQL;
32
- qb.toSQL = () => {
33
- const res = originalToSQL.apply(qb);
34
- return {
35
- ...res,
36
- sql: `set identity_insert ${table} on; ${res.sql}; set identity_insert ${table} off;`,
37
- toNative: () => res.toNative(),
38
- };
39
- };
40
- }
41
11
  checkIdentityInsert(data) {
42
12
  const meta = this.metadata.find(this.mainAlias.entityName);
43
13
  if (!meta) {
@@ -1,4 +1,4 @@
1
- import { type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type Dictionary, type ForeignKey, type IndexDef, type Knex, SchemaHelper, type Table, type TableDifference, type Type } from '@mikro-orm/knex';
1
+ import { type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type Dictionary, type ForeignKey, type IndexDef, SchemaHelper, type Table, type TableDifference, type Type } from '@mikro-orm/knex';
2
2
  export declare class MsSqlSchemaHelper extends SchemaHelper {
3
3
  static readonly DEFAULT_VALUES: {
4
4
  true: string[];
@@ -16,23 +16,27 @@ export declare class MsSqlSchemaHelper extends SchemaHelper {
16
16
  getAllIndexes(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<IndexDef[]>>;
17
17
  mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary;
18
18
  getAllForeignKeys(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<Dictionary<ForeignKey>>>;
19
- getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName?: string, schemaName?: string): Promise<Dictionary<string[]>>;
19
+ private getEnumDefinitions;
20
20
  private getChecksSQL;
21
21
  getAllChecks(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<CheckDef[]>>;
22
22
  loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[]): Promise<void>;
23
- getPreAlterTable(tableDiff: TableDifference, safe: boolean): string;
24
- getPostAlterTable(tableDiff: TableDifference, safe: boolean): string;
23
+ getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
24
+ getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
25
25
  getCreateNamespaceSQL(name: string): string;
26
26
  getDropNamespaceSQL(name: string): string;
27
27
  getDropIndexSQL(tableName: string, index: IndexDef): string;
28
+ dropIndex(table: string, index: IndexDef, oldIndexName?: string): string;
28
29
  getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
30
+ private getDropDefaultsSQL;
29
31
  getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string;
30
- createTableColumn(table: Knex.TableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>, alter?: boolean): Knex.ColumnBuilder | undefined;
32
+ createTableColumn(column: Column, table: DatabaseTable, changedProperties?: Set<string>): string | undefined;
33
+ alterTableColumn(column: Column, table: DatabaseTable, changedProperties: Set<string>): string[];
34
+ getCreateIndexSQL(tableName: string, index: IndexDef, partialExpression?: boolean): string;
35
+ createIndex(index: IndexDef, table: DatabaseTable, createPrimary?: boolean): string;
36
+ dropForeignKey(tableName: string, constraintName: string): string;
37
+ dropTableIfExists(name: string, schema?: string): string;
38
+ getAddColumnsSQL(table: DatabaseTable, columns: Column[]): string[];
39
+ appendComments(table: DatabaseTable): string[];
31
40
  inferLengthFromColumnType(type: string): number | undefined;
32
41
  protected wrap(val: string | undefined, type: Type<unknown>): string | undefined;
33
- /**
34
- * MSSQL supports `\n` in SQL and stores `\\n` literally.
35
- * This method overrides the parent behavior to prevent replacing `\n` with `\\n`.
36
- */
37
- handleMultilineComment(comment: string): string;
38
42
  }
@@ -53,6 +53,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
53
53
  table_schema as schema_name,
54
54
  column_name as column_name,
55
55
  column_default as column_default,
56
+ t5.name as column_default_name,
56
57
  t4.value as column_comment,
57
58
  ic.is_nullable as is_nullable,
58
59
  data_type as data_type,
@@ -67,6 +68,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
67
68
  inner join sys.columns sc on sc.name = ic.column_name and sc.object_id = object_id(ic.table_schema + '.' + ic.table_name)
68
69
  left join sys.computed_columns cmp on cmp.name = ic.column_name and cmp.object_id = object_id(ic.table_schema + '.' + ic.table_name)
69
70
  left join sys.extended_properties t4 on t4.major_id = object_id(ic.table_schema + '.' + ic.table_name) and t4.name = 'MS_Description' and t4.minor_id = sc.column_id
71
+ left join sys.default_constraints t5 on sc.default_object_id = t5.object_id
70
72
  where (${[...tablesBySchemas.entries()].map(([schema, tables]) => `(ic.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(',')}) and ic.table_schema = '${schema}')`).join(' OR ')})
71
73
  order by ordinal_position`;
72
74
  const allColumns = await connection.execute(sql);
@@ -103,6 +105,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
103
105
  unsigned: col.data_type.endsWith(' unsigned'),
104
106
  length: col.length,
105
107
  default: this.wrap(defaultValue, mappedType),
108
+ defaultConstraint: col.column_default_name,
106
109
  nullable: col.is_nullable === 'YES',
107
110
  autoincrement: increments,
108
111
  precision: col.numeric_precision,
@@ -184,10 +187,9 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
184
187
  });
185
188
  return ret;
186
189
  }
187
- async getEnumDefinitions(connection, checks, tableName, schemaName) {
188
- const found = [];
189
- const enums = checks.reduce((o, item, index) => {
190
- // check constraints are defined as one of:
190
+ getEnumDefinitions(checks) {
191
+ return checks.reduce((o, item, index) => {
192
+ // check constraints are defined as
191
193
  // `([type]='owner' OR [type]='manager' OR [type]='employee')`
192
194
  const m1 = item.definition?.match(/^check \((.*)\)/);
193
195
  let items = m1?.[1].split(' OR ');
@@ -197,13 +199,10 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
197
199
  items = items.map(val => val.trim().replace(`[${item.columnName}]=`, '').match(/^\(?'(.*)'/)?.[1]).filter(Boolean);
198
200
  if (items.length > 0) {
199
201
  o[item.columnName] = items.reverse();
200
- found.push(index);
201
202
  }
202
203
  }
203
204
  return o;
204
205
  }, {});
205
- found.reverse().forEach(index => checks.splice(index, 1));
206
- return enums;
207
206
  }
208
207
  getChecksSQL(tablesBySchemas) {
209
208
  return `select con.name as name,
@@ -224,11 +223,12 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
224
223
  for (const check of allChecks) {
225
224
  const key = this.getTableKey(check);
226
225
  ret[key] ??= [];
226
+ const expression = check.expression.replace(/^\((.*)\)$/, '$1');
227
227
  ret[key].push({
228
228
  name: check.name,
229
229
  columnName: check.column_name,
230
- definition: 'check ' + check.expression,
231
- expression: check.expression,
230
+ definition: `check (${expression})`,
231
+ expression,
232
232
  });
233
233
  }
234
234
  return ret;
@@ -246,7 +246,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
246
246
  const key = this.getTableKey(t);
247
247
  const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
248
248
  const pks = await this.getPrimaryKeys(connection, indexes[key], table.name, table.schema);
249
- const enums = await this.getEnumDefinitions(connection, checks[key] ?? []);
249
+ const enums = this.getEnumDefinitions(checks[key] ?? []);
250
250
  table.init(columns[key], indexes[key], checks[key], pks, fks[key], enums);
251
251
  }
252
252
  }
@@ -258,17 +258,9 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
258
258
  const schemaName = parts.pop();
259
259
  /* istanbul ignore next */
260
260
  const name = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName;
261
- const quotedName = this.platform.quoteIdentifier(name);
261
+ const quotedName = this.quote(name);
262
262
  // indexes need to be first dropped to be able to change a column type
263
263
  const changedTypes = Object.values(tableDiff.changedColumns).filter(col => col.changedProperties.has('type'));
264
- // detect that the column was an enum before and remove the check constraint in such case here
265
- const changedEnums = Object.values(tableDiff.changedColumns).filter(col => col.fromColumn.mappedType instanceof knex_1.EnumType);
266
- for (const col of changedEnums) {
267
- if (col.changedProperties.has('enumItems')) {
268
- const checkName = this.platform.getConfig().getNamingStrategy().indexName(tableName, [col.column.name], 'check');
269
- ret.push(`alter table ${quotedName} drop constraint if exists [${checkName}]`);
270
- }
271
- }
272
264
  for (const col of changedTypes) {
273
265
  for (const index of indexes) {
274
266
  if (index.columnNames.includes(col.column.name)) {
@@ -281,7 +273,7 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
281
273
  ret.push(`alter table ${quotedName} alter column [${col.oldColumnName}] nvarchar(max)`);
282
274
  }
283
275
  }
284
- return ret.join(';\n');
276
+ return ret;
285
277
  }
286
278
  getPostAlterTable(tableDiff, safe) {
287
279
  const ret = [];
@@ -296,38 +288,58 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
296
288
  for (const col of changedTypes) {
297
289
  for (const index of indexes) {
298
290
  if (index.columnNames.includes(col.column.name)) {
299
- ret.push(this.getCreateIndexSQL(name, index));
291
+ this.append(ret, this.getCreateIndexSQL(name, index));
300
292
  }
301
293
  }
302
294
  }
303
- return ret.join(';\n');
295
+ return ret;
304
296
  }
305
297
  getCreateNamespaceSQL(name) {
306
- return `if (schema_id(${this.platform.quoteValue(name)}) is null) begin exec ('create schema ${this.platform.quoteIdentifier(name)} authorization [dbo]') end`;
298
+ return `if (schema_id(${this.platform.quoteValue(name)}) is null) begin exec ('create schema ${this.quote(name)} authorization [dbo]') end`;
307
299
  }
308
300
  getDropNamespaceSQL(name) {
309
- return `drop schema if exists ${this.platform.quoteIdentifier(name)}`;
301
+ return `drop schema if exists ${this.quote(name)}`;
310
302
  }
311
303
  getDropIndexSQL(tableName, index) {
312
- return `drop index ${this.platform.quoteIdentifier(index.keyName)} on ${this.platform.quoteIdentifier(tableName)}`;
304
+ return `drop index ${this.quote(index.keyName)} on ${this.quote(tableName)}`;
305
+ }
306
+ dropIndex(table, index, oldIndexName = index.keyName) {
307
+ if (index.primary) {
308
+ return `alter table ${this.quote(table)} drop constraint ${this.quote(oldIndexName)}`;
309
+ }
310
+ return `drop index ${this.quote(oldIndexName)} on ${this.quote(table)}`;
313
311
  }
314
312
  getDropColumnsSQL(tableName, columns, schemaName) {
315
313
  /* istanbul ignore next */
316
- const tableNameRaw = this.platform.quoteIdentifier((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
314
+ const tableNameRaw = this.quote((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
317
315
  const drops = [];
316
+ const constraints = this.getDropDefaultsSQL(tableName, columns, schemaName);
317
+ for (const column of columns) {
318
+ drops.push(this.quote(column.name));
319
+ }
320
+ return `${constraints.join(';\n')};\nalter table ${tableNameRaw} drop column ${drops.join(', ')}`;
321
+ }
322
+ getDropDefaultsSQL(tableName, columns, schemaName) {
323
+ /* istanbul ignore next */
324
+ const tableNameRaw = this.quote((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
318
325
  const constraints = [];
319
- let i = 0;
326
+ schemaName ??= this.platform.getDefaultSchemaName();
320
327
  for (const column of columns) {
328
+ if (column.defaultConstraint) {
329
+ constraints.push(`alter table ${tableNameRaw} drop constraint ${this.quote(column.defaultConstraint)}`);
330
+ continue;
331
+ }
332
+ const i = globalThis.idx;
333
+ globalThis.idx++;
334
+ /* istanbul ignore next */
321
335
  constraints.push(`declare @constraint${i} varchar(100) = (select default_constraints.name from sys.all_columns`
322
336
  + ' join sys.tables on all_columns.object_id = tables.object_id'
323
337
  + ' join sys.schemas on tables.schema_id = schemas.schema_id'
324
338
  + ' join sys.default_constraints on all_columns.default_object_id = default_constraints.object_id'
325
339
  + ` where schemas.name = '${schemaName}' and tables.name = '${tableName}' and all_columns.name = '${column.name}')`
326
340
  + ` if @constraint${i} is not null exec('alter table ${tableNameRaw} drop constraint ' + @constraint${i})`);
327
- drops.push(this.platform.quoteIdentifier(column.name));
328
- i++;
329
341
  }
330
- return `${constraints.join(';\n')};\nalter table ${tableNameRaw} drop column ${drops.join(', ')}`;
342
+ return constraints;
331
343
  }
332
344
  getRenameColumnSQL(tableName, oldColumnName, to, schemaName) {
333
345
  /* istanbul ignore next */
@@ -335,22 +347,109 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
335
347
  const columnName = this.platform.quoteValue(to.name);
336
348
  return `exec sp_rename ${this.platform.quoteValue(oldName)}, ${columnName}, 'COLUMN'`;
337
349
  }
338
- createTableColumn(table, column, fromTable, changedProperties, alter) {
339
- if (changedProperties && column.mappedType instanceof knex_1.EnumType && column.enumItems?.every(item => knex_1.Utils.isString(item))) {
340
- const checkName = this.platform.getConfig().getNamingStrategy().indexName(fromTable.name, [column.name], 'check');
341
- if (changedProperties.has('enumItems')) {
342
- table.check(`${this.platform.quoteIdentifier(column.name)} in ('${(column.enumItems.join("', '"))}')`, {}, this.platform.quoteIdentifier(checkName));
343
- }
344
- /* istanbul ignore next */
345
- if (changedProperties.has('type')) {
346
- return table.specificType(column.name, column.type);
347
- }
348
- return undefined;
350
+ createTableColumn(column, table, changedProperties) {
351
+ const compositePK = table.getPrimaryKey()?.composite;
352
+ const primaryKey = !changedProperties && !this.hasNonDefaultPrimaryKeyName(table);
353
+ const columnType = column.generated ? `as ${column.generated}` : column.type;
354
+ const col = [this.quote(column.name)];
355
+ if (column.autoincrement && !column.generated && !compositePK && (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
356
+ col.push(column.mappedType.getColumnType({ autoincrement: true }, this.platform));
357
+ }
358
+ else {
359
+ col.push(columnType);
349
360
  }
350
- if (column.generated) {
351
- return table.specificType(column.name, `as ${column.generated}`);
361
+ knex_1.Utils.runIfNotEmpty(() => col.push('identity(1,1)'), column.autoincrement);
362
+ knex_1.Utils.runIfNotEmpty(() => col.push('null'), column.nullable);
363
+ knex_1.Utils.runIfNotEmpty(() => col.push('not null'), !column.nullable && !column.generated);
364
+ if (column.autoincrement && !column.generated && !compositePK && (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
365
+ knex_1.Utils.runIfNotEmpty(() => col.push('primary key'), primaryKey && column.primary);
352
366
  }
353
- return super.createTableColumn(table, column, fromTable, changedProperties);
367
+ const useDefault = changedProperties ? false : column.default != null && column.default !== 'null' && !column.autoincrement;
368
+ const defaultName = this.platform.getConfig().getNamingStrategy().indexName(table.name, [column.name], 'default');
369
+ knex_1.Utils.runIfNotEmpty(() => col.push(`constraint ${this.quote(defaultName)} default ${column.default}`), useDefault);
370
+ return col.join(' ');
371
+ }
372
+ alterTableColumn(column, table, changedProperties) {
373
+ const parts = [];
374
+ if (changedProperties.has('default')) {
375
+ const [constraint] = this.getDropDefaultsSQL(table.name, [column], table.schema);
376
+ parts.push(constraint);
377
+ }
378
+ if (changedProperties.has('type') || changedProperties.has('nullable')) {
379
+ const col = this.createTableColumn(column, table, changedProperties);
380
+ parts.push(`alter table ${table.getQuotedName()} alter column ${col}`);
381
+ }
382
+ if (changedProperties.has('default') && column.default != null) {
383
+ const defaultName = this.platform.getConfig().getNamingStrategy().indexName(table.name, [column.name], 'default');
384
+ parts.push(`alter table ${table.getQuotedName()} add constraint ${this.quote(defaultName)} default ${column.default} for ${this.quote(column.name)}`);
385
+ }
386
+ return parts;
387
+ }
388
+ getCreateIndexSQL(tableName, index, partialExpression = false) {
389
+ /* istanbul ignore next */
390
+ if (index.expression && !partialExpression) {
391
+ return index.expression;
392
+ }
393
+ const keyName = this.quote(index.keyName);
394
+ const defer = index.deferMode ? ` deferrable initially ${index.deferMode}` : '';
395
+ const sql = `create ${index.unique ? 'unique ' : ''}index ${keyName} on ${this.quote(tableName)} `;
396
+ if (index.expression && partialExpression) {
397
+ return `${sql}(${index.expression})${defer}`;
398
+ }
399
+ return super.getCreateIndexSQL(tableName, index);
400
+ }
401
+ createIndex(index, table, createPrimary = false) {
402
+ if (index.primary) {
403
+ return '';
404
+ }
405
+ if (index.expression) {
406
+ return index.expression;
407
+ }
408
+ const quotedTableName = table.getQuotedName();
409
+ if (index.unique) {
410
+ const nullable = index.columnNames.some(column => table.getColumn(column)?.nullable);
411
+ const where = nullable ? ' where ' + index.columnNames.map(c => `${this.quote(c)} is not null`).join(' and ') : '';
412
+ return `create unique index ${this.quote(index.keyName)} on ${quotedTableName} (${index.columnNames.map(c => this.quote(c)).join(', ')})${where}`;
413
+ }
414
+ return super.createIndex(index, table);
415
+ }
416
+ dropForeignKey(tableName, constraintName) {
417
+ return `alter table ${this.quote(tableName)} drop constraint ${this.quote(constraintName)}`;
418
+ }
419
+ dropTableIfExists(name, schema) {
420
+ if (schema === this.platform.getDefaultSchemaName()) {
421
+ schema = undefined;
422
+ }
423
+ return `if object_id('${this.quote(schema, name)}', 'U') is not null drop table ${this.quote(schema, name)}`;
424
+ }
425
+ getAddColumnsSQL(table, columns) {
426
+ const adds = columns.map(column => {
427
+ return `${this.createTableColumn(column, table)}`;
428
+ }).join(', ');
429
+ return [`alter table ${table.getQuotedName()} add ${adds}`];
430
+ }
431
+ appendComments(table) {
432
+ const sql = [];
433
+ const schema = this.platform.quoteValue(table.schema);
434
+ const tableName = this.platform.quoteValue(table.name);
435
+ if (table.comment) {
436
+ const comment = this.platform.quoteValue(table.comment);
437
+ sql.push(`if exists(select * from sys.fn_listextendedproperty(N'MS_Description', N'Schema', N${schema}, N'Table', N${tableName}, null, null))
438
+ exec sys.sp_updateextendedproperty N'MS_Description', N${comment}, N'Schema', N${schema}, N'Table', N${tableName}
439
+ else
440
+ exec sys.sp_addextendedproperty N'MS_Description', N${comment}, N'Schema', N${schema}, N'Table', N${tableName}`);
441
+ }
442
+ for (const column of table.getColumns()) {
443
+ if (column.comment) {
444
+ const comment = this.platform.quoteValue(column.comment);
445
+ const columnName = this.platform.quoteValue(column.name);
446
+ sql.push(`if exists(select * from sys.fn_listextendedproperty(N'MS_Description', N'Schema', N${schema}, N'Table', N${tableName}, N'Column', N${columnName}))
447
+ exec sys.sp_updateextendedproperty N'MS_Description', N${comment}, N'Schema', N${schema}, N'Table', N${tableName}, N'Column', N${columnName}
448
+ else
449
+ exec sys.sp_addextendedproperty N'MS_Description', N${comment}, N'Schema', N${schema}, N'Table', N${tableName}, N'Column', N${columnName}`);
450
+ }
451
+ }
452
+ return sql;
354
453
  }
355
454
  inferLengthFromColumnType(type) {
356
455
  const match = type.match(/^(\w+)\s*\(\s*(-?\d+|max)\s*\)/);
@@ -366,12 +465,5 @@ class MsSqlSchemaHelper extends knex_1.SchemaHelper {
366
465
  const stringType = type instanceof knex_1.StringType || type instanceof knex_1.TextType || type instanceof knex_1.EnumType || type instanceof UnicodeStringType_1.UnicodeStringType;
367
466
  return typeof val === 'string' && val.length > 0 && stringType ? this.platform.quoteValue(val) : val;
368
467
  }
369
- /**
370
- * MSSQL supports `\n` in SQL and stores `\\n` literally.
371
- * This method overrides the parent behavior to prevent replacing `\n` with `\\n`.
372
- */
373
- handleMultilineComment(comment) {
374
- return comment;
375
- }
376
468
  }
377
469
  exports.MsSqlSchemaHelper = MsSqlSchemaHelper;
package/README.md CHANGED
@@ -183,7 +183,6 @@ yarn add @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
183
183
  yarn add @mikro-orm/core @mikro-orm/postgresql # for postgresql
184
184
  yarn add @mikro-orm/core @mikro-orm/mssql # for mssql
185
185
  yarn add @mikro-orm/core @mikro-orm/sqlite # for sqlite
186
- yarn add @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
187
186
  yarn add @mikro-orm/core @mikro-orm/libsql # for libsql
188
187
  ```
189
188
 
@@ -196,7 +195,6 @@ npm i -s @mikro-orm/core @mikro-orm/mariadb # for mysql/mariadb
196
195
  npm i -s @mikro-orm/core @mikro-orm/postgresql # for postgresql
197
196
  npm i -s @mikro-orm/core @mikro-orm/mssql # for mssql
198
197
  npm i -s @mikro-orm/core @mikro-orm/sqlite # for sqlite
199
- npm i -s @mikro-orm/core @mikro-orm/better-sqlite # for better-sqlite
200
198
  npm i -s @mikro-orm/core @mikro-orm/libsql # for libsql
201
199
  ```
202
200
 
package/index.mjs CHANGED
@@ -19,12 +19,10 @@ export const ArrayType = mod.ArrayType;
19
19
  export const BaseEntity = mod.BaseEntity;
20
20
  export const BaseSqliteConnection = mod.BaseSqliteConnection;
21
21
  export const BaseSqlitePlatform = mod.BaseSqlitePlatform;
22
- export const BaseSqliteSchemaHelper = mod.BaseSqliteSchemaHelper;
23
22
  export const BeforeCreate = mod.BeforeCreate;
24
23
  export const BeforeDelete = mod.BeforeDelete;
25
24
  export const BeforeUpdate = mod.BeforeUpdate;
26
25
  export const BeforeUpsert = mod.BeforeUpsert;
27
- export const BetterSqliteKnexDialect = mod.BetterSqliteKnexDialect;
28
26
  export const BigIntType = mod.BigIntType;
29
27
  export const BlobType = mod.BlobType;
30
28
  export const BooleanType = mod.BooleanType;
@@ -112,14 +110,12 @@ export const JSON_KEY_OPERATORS = mod.JSON_KEY_OPERATORS;
112
110
  export const JoinType = mod.JoinType;
113
111
  export const JsonProperty = mod.JsonProperty;
114
112
  export const JsonType = mod.JsonType;
115
- export const Knex = mod.Knex;
116
- export const LibSqlKnexDialect = mod.LibSqlKnexDialect;
113
+ export const Kysely = mod.Kysely;
117
114
  export const LoadStrategy = mod.LoadStrategy;
118
115
  export const LockMode = mod.LockMode;
119
116
  export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
120
117
  export const ManyToMany = mod.ManyToMany;
121
118
  export const ManyToOne = mod.ManyToOne;
122
- export const MariaDbKnexDialect = mod.MariaDbKnexDialect;
123
119
  export const MediumIntType = mod.MediumIntType;
124
120
  export const MemoryCacheAdapter = mod.MemoryCacheAdapter;
125
121
  export const MetadataDiscovery = mod.MetadataDiscovery;
@@ -129,18 +125,17 @@ export const MetadataStorage = mod.MetadataStorage;
129
125
  export const MetadataValidator = mod.MetadataValidator;
130
126
  export const MikroORM = mod.MikroORM;
131
127
  export const MongoNamingStrategy = mod.MongoNamingStrategy;
132
- export const MonkeyPatchable = mod.MonkeyPatchable;
133
128
  export const MsSqlConnection = mod.MsSqlConnection;
134
129
  export const MsSqlDriver = mod.MsSqlDriver;
135
130
  export const MsSqlExceptionConverter = mod.MsSqlExceptionConverter;
136
- export const MsSqlKnexDialect = mod.MsSqlKnexDialect;
131
+ export const MsSqlNativeQueryBuilder = mod.MsSqlNativeQueryBuilder;
137
132
  export const MsSqlPlatform = mod.MsSqlPlatform;
138
133
  export const MsSqlSchemaHelper = mod.MsSqlSchemaHelper;
139
- export const MySqlConnection = mod.MySqlConnection;
140
134
  export const MySqlExceptionConverter = mod.MySqlExceptionConverter;
141
- export const MySqlKnexDialect = mod.MySqlKnexDialect;
135
+ export const MySqlNativeQueryBuilder = mod.MySqlNativeQueryBuilder;
142
136
  export const MySqlPlatform = mod.MySqlPlatform;
143
137
  export const MySqlSchemaHelper = mod.MySqlSchemaHelper;
138
+ export const NativeQueryBuilder = mod.NativeQueryBuilder;
144
139
  export const NodeState = mod.NodeState;
145
140
  export const NonUniqueFieldNameException = mod.NonUniqueFieldNameException;
146
141
  export const NotFoundError = mod.NotFoundError;
@@ -160,7 +155,7 @@ export const PlainObject = mod.PlainObject;
160
155
  export const Platform = mod.Platform;
161
156
  export const PopulateHint = mod.PopulateHint;
162
157
  export const PopulatePath = mod.PopulatePath;
163
- export const PostgreSqlKnexDialect = mod.PostgreSqlKnexDialect;
158
+ export const PostgreSqlNativeQueryBuilder = mod.PostgreSqlNativeQueryBuilder;
164
159
  export const PrimaryKey = mod.PrimaryKey;
165
160
  export const PrimaryKeyProp = mod.PrimaryKeyProp;
166
161
  export const Property = mod.Property;
@@ -172,6 +167,7 @@ export const QueryOperator = mod.QueryOperator;
172
167
  export const QueryOrder = mod.QueryOrder;
173
168
  export const QueryOrderNumeric = mod.QueryOrderNumeric;
174
169
  export const QueryType = mod.QueryType;
170
+ export const Raw = mod.Raw;
175
171
  export const RawQueryFragment = mod.RawQueryFragment;
176
172
  export const ReadOnlyException = mod.ReadOnlyException;
177
173
  export const Ref = mod.Ref;
@@ -193,8 +189,9 @@ export const SmallIntType = mod.SmallIntType;
193
189
  export const SqlEntityManager = mod.SqlEntityManager;
194
190
  export const SqlEntityRepository = mod.SqlEntityRepository;
195
191
  export const SqlSchemaGenerator = mod.SqlSchemaGenerator;
196
- export const SqliteKnexDialect = mod.SqliteKnexDialect;
197
- export const SqliteTableCompiler = mod.SqliteTableCompiler;
192
+ export const SqliteExceptionConverter = mod.SqliteExceptionConverter;
193
+ export const SqliteNativeQueryBuilder = mod.SqliteNativeQueryBuilder;
194
+ export const SqliteSchemaHelper = mod.SqliteSchemaHelper;
198
195
  export const StringType = mod.StringType;
199
196
  export const SyntaxErrorException = mod.SyntaxErrorException;
200
197
  export const TableExistsException = mod.TableExistsException;
@@ -230,7 +227,7 @@ export const equals = mod.equals;
230
227
  export const getOnConflictFields = mod.getOnConflictFields;
231
228
  export const getOnConflictReturningFields = mod.getOnConflictReturningFields;
232
229
  export const helper = mod.helper;
233
- export const knex = mod.knex;
230
+ export const isRaw = mod.isRaw;
234
231
  export const parseJsonSafe = mod.parseJsonSafe;
235
232
  export const raw = mod.raw;
236
233
  export const ref = mod.ref;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mssql",
3
- "version": "6.4.7-dev.1",
3
+ "version": "7.0.0-dev.1",
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",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "homepage": "https://mikro-orm.io",
48
48
  "engines": {
49
- "node": ">= 18.12.0"
49
+ "node": ">= 22.11.0"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "yarn clean && yarn compile && yarn copy && yarn run -T gen-esm-wrapper index.js index.mjs",
@@ -58,14 +58,17 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@mikro-orm/knex": "6.4.7-dev.1",
61
+ "@mikro-orm/knex": "7.0.0-dev.1",
62
+ "tarn": "3.0.2",
62
63
  "tedious": "19.0.0",
63
64
  "tsqlstring": "1.0.1"
64
65
  },
65
66
  "devDependencies": {
66
- "@mikro-orm/core": "^6.4.6"
67
+ "@mikro-orm/core": "^6.4.5",
68
+ "kysely": "https://pkg.pr.new/kysely-org/kysely/kysely@2b7007e"
67
69
  },
68
70
  "peerDependencies": {
69
- "@mikro-orm/core": "6.4.7-dev.1"
71
+ "@mikro-orm/core": "7.0.0-dev.1",
72
+ "kysely": "*"
70
73
  }
71
74
  }