@mikro-orm/mssql 7.1.10-dev.7 → 7.1.10-dev.9

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.
@@ -52,6 +52,8 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
52
52
  }): string;
53
53
  getDefaultMappedType(type: string): Type<unknown>;
54
54
  getDefaultSchemaName(): string | undefined;
55
+ getDefaultPrimaryName(tableName: string, columns: string[]): string;
56
+ supportsCustomPrimaryKeyNames(): boolean;
55
57
  getUuidTypeDeclarationSQL(column: {
56
58
  length?: number;
57
59
  }): string;
package/MsSqlPlatform.js CHANGED
@@ -139,6 +139,12 @@ export class MsSqlPlatform extends AbstractSqlPlatform {
139
139
  getDefaultSchemaName() {
140
140
  return 'dbo';
141
141
  }
142
+ getDefaultPrimaryName(tableName, columns) {
143
+ return this.getIndexName(tableName, columns, 'primary');
144
+ }
145
+ supportsCustomPrimaryKeyNames() {
146
+ return true;
147
+ }
142
148
  getUuidTypeDeclarationSQL(column) {
143
149
  return 'uniqueidentifier';
144
150
  }
@@ -51,6 +51,7 @@ export declare class MsSqlSchemaHelper extends SchemaHelper {
51
51
  private getDropDefaultsSQL;
52
52
  getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string;
53
53
  createTableColumn(column: Column, table: DatabaseTable, changedProperties?: Set<string>): string | undefined;
54
+ protected getPrimaryKeyConstraintPrefix(table: DatabaseTable, index: IndexDef): string;
54
55
  alterTableColumn(column: Column, table: DatabaseTable, changedProperties: Set<string>): string[];
55
56
  getCreateIndexSQL(tableName: string, index: IndexDef, partialExpression?: boolean): string;
56
57
  /**
@@ -670,7 +670,8 @@ export class MsSqlSchemaHelper extends SchemaHelper {
670
670
  !column.generated &&
671
671
  !compositePK &&
672
672
  (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
673
- Utils.runIfNotEmpty(() => col.push('primary key'), primaryKey && column.primary);
673
+ const primaryKeyName = this.platform.getDefaultPrimaryName(table.name, [column.name]);
674
+ Utils.runIfNotEmpty(() => col.push(`constraint ${this.quote(primaryKeyName)} primary key`), primaryKey && column.primary);
674
675
  }
675
676
  const useDefault = changedProperties
676
677
  ? false
@@ -679,6 +680,10 @@ export class MsSqlSchemaHelper extends SchemaHelper {
679
680
  Utils.runIfNotEmpty(() => col.push(`constraint ${this.quote(defaultName)} default ${column.default}`), useDefault);
680
681
  return col.join(' ');
681
682
  }
683
+ // SQL Server generates a random `PK__…` name when the constraint is unnamed, so always name it
684
+ getPrimaryKeyConstraintPrefix(table, index) {
685
+ return `constraint ${this.quote(index.keyName)} `;
686
+ }
682
687
  alterTableColumn(column, table, changedProperties) {
683
688
  const parts = [];
684
689
  if (changedProperties.has('default')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mssql",
3
- "version": "7.1.10-dev.7",
3
+ "version": "7.1.10-dev.9",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -47,7 +47,7 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "@mikro-orm/sql": "7.1.10-dev.7",
50
+ "@mikro-orm/sql": "7.1.10-dev.9",
51
51
  "kysely": "0.29.4",
52
52
  "tarn": "3.1.2",
53
53
  "tedious": "20.0.0",
@@ -57,7 +57,7 @@
57
57
  "@mikro-orm/core": "^7.1.9"
58
58
  },
59
59
  "peerDependencies": {
60
- "@mikro-orm/core": "7.1.10-dev.7"
60
+ "@mikro-orm/core": "7.1.10-dev.9"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">= 22.17.0"