@mikro-orm/mssql 7.0.0-dev.114 → 7.0.0-dev.115

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/MsSqlDriver.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction, type Constructor } from '@mikro-orm/core';
1
+ import { type AnyEntity, type Configuration, type ConnectionType, type EntityDictionary, type LoggingOptions, type NativeInsertUpdateManyOptions, type QueryResult, type Transaction, type Constructor, type EntityName } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver, type SqlEntityManager } from '@mikro-orm/sql';
3
3
  import { MsSqlConnection } from './MsSqlConnection.js';
4
4
  import { MsSqlQueryBuilder } from './MsSqlQueryBuilder.js';
5
5
  import { MsSqlMikroORM } from './MsSqlMikroORM.js';
6
6
  export declare class MsSqlDriver extends AbstractSqlDriver<MsSqlConnection> {
7
7
  constructor(config: Configuration);
8
- nativeInsertMany<T extends AnyEntity<T>>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
9
- createQueryBuilder<T extends AnyEntity<T>>(entityName: string, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): MsSqlQueryBuilder<T, any, any, any>;
8
+ nativeInsertMany<T extends AnyEntity<T>>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
9
+ 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>;
10
10
  private appendOutputTable;
11
11
  /** @inheritDoc */
12
12
  getORMClass(): Constructor<MsSqlMikroORM>;
package/MsSqlDriver.js CHANGED
@@ -25,7 +25,7 @@ export class MsSqlDriver extends AbstractSqlDriver {
25
25
  const output = returningFields.length > 0 ? `output ${returningFields.map(field => 'inserted.' + this.platform.quoteIdentifier(field)).join(', ')}` : '';
26
26
  const sql = `merge into ${tableName} using (${using2}) s on 1 = 0 when not matched then insert default values ${output};`;
27
27
  const res = await this.execute(sql, [], 'run', options.ctx);
28
- const pks = this.getPrimaryKeyFields(entityName);
28
+ const pks = this.getPrimaryKeyFields(meta);
29
29
  if (pks.length === 1) {
30
30
  res.row ??= {};
31
31
  res.rows ??= [];
@@ -4,7 +4,7 @@ export class MsSqlQueryBuilder extends QueryBuilder {
4
4
  insert(data) {
5
5
  this.checkIdentityInsert(data);
6
6
  if (!this.flags.has(QueryFlag.IDENTITY_INSERT) && this.metadata.has(this.mainAlias.entityName)) {
7
- const meta = this.metadata.find(this.mainAlias.entityName);
7
+ const meta = this.mainAlias.meta;
8
8
  if (meta.hasTriggers) {
9
9
  this.setFlag(QueryFlag.OUTPUT_TABLE);
10
10
  }
@@ -12,11 +12,8 @@ export class MsSqlQueryBuilder extends QueryBuilder {
12
12
  return super.insert(data);
13
13
  }
14
14
  checkIdentityInsert(data) {
15
- const meta = this.metadata.find(this.mainAlias.entityName);
16
- if (!meta) {
17
- return;
18
- }
19
- const dataKeys = Utils.unique(Utils.asArray(data).flatMap(Object.keys));
15
+ const meta = this.mainAlias.meta;
16
+ const dataKeys = Utils.unique(Utils.asArray(data).flatMap(Utils.keys));
20
17
  const hasAutoincrement = dataKeys.some(x => meta.properties[x]?.autoincrement);
21
18
  if (hasAutoincrement) {
22
19
  this.setFlag(QueryFlag.IDENTITY_INSERT);
@@ -11,7 +11,7 @@ export class MsSqlSchemaGenerator extends SchemaGenerator {
11
11
  }
12
12
  // https://stackoverflow.com/questions/253849/cannot-truncate-table-because-it-is-being-referenced-by-a-foreign-key-constraint
13
13
  for (const meta of this.getOrderedMetadata(options?.schema).reverse()) {
14
- const res = await this.driver.nativeDelete(meta.className, {}, options);
14
+ const res = await this.driver.nativeDelete(meta.class, {}, options);
15
15
  if (meta.getPrimaryProps().some(pk => pk.autoincrement)) {
16
16
  const tableName = this.driver.getTableName(meta, { schema: options?.schema }, false);
17
17
  await this.execute(`dbcc checkident ('${tableName}', reseed, ${res.affectedRows > 0 ? 0 : 1})`, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/mssql",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.114",
4
+ "version": "7.0.0-dev.115",
5
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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/sql": "7.0.0-dev.114",
53
+ "@mikro-orm/sql": "7.0.0-dev.115",
54
54
  "kysely": "0.28.9",
55
55
  "tarn": "3.0.2",
56
56
  "tedious": "19.1.3",
@@ -60,6 +60,6 @@
60
60
  "@mikro-orm/core": "^6.6.2"
61
61
  },
62
62
  "peerDependencies": {
63
- "@mikro-orm/core": "7.0.0-dev.114"
63
+ "@mikro-orm/core": "7.0.0-dev.115"
64
64
  }
65
65
  }