@mikro-orm/sql 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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.10-dev.
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.1.9"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.10-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.10-dev.9"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/schema/SchemaHelper.d.ts
CHANGED
|
@@ -124,6 +124,8 @@ export declare abstract class SchemaHelper {
|
|
|
124
124
|
getAddColumnsSQL(table: DatabaseTable, columns: Column[]): string[];
|
|
125
125
|
getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
|
|
126
126
|
hasNonDefaultPrimaryKeyName(table: DatabaseTable): boolean;
|
|
127
|
+
/** Returns the `constraint <name> ` prefix for a primary key definition, empty when the server assigns the default name on its own. */
|
|
128
|
+
protected getPrimaryKeyConstraintPrefix(table: DatabaseTable, index: IndexDef): string;
|
|
127
129
|
castColumn(name: string, type: string): string;
|
|
128
130
|
alterTableColumn(column: Column, table: DatabaseTable, changedProperties: Set<string>): string[];
|
|
129
131
|
/** Returns the bare `collate <name>` clause for column DDL. Overridden by PostgreSQL to quote the identifier. */
|
package/schema/SchemaHelper.js
CHANGED
|
@@ -521,6 +521,10 @@ export class SchemaHelper {
|
|
|
521
521
|
const defaultName = this.platform.getDefaultPrimaryName(table.name, pkIndex.columnNames);
|
|
522
522
|
return pkIndex?.keyName !== defaultName;
|
|
523
523
|
}
|
|
524
|
+
/** Returns the `constraint <name> ` prefix for a primary key definition, empty when the server assigns the default name on its own. */
|
|
525
|
+
getPrimaryKeyConstraintPrefix(table, index) {
|
|
526
|
+
return this.hasNonDefaultPrimaryKeyName(table) ? `constraint ${this.quote(index.keyName)} ` : '';
|
|
527
|
+
}
|
|
524
528
|
/* v8 ignore next */
|
|
525
529
|
castColumn(name, type) {
|
|
526
530
|
return '';
|
|
@@ -766,7 +770,7 @@ export class SchemaHelper {
|
|
|
766
770
|
const primaryKey = table.getPrimaryKey();
|
|
767
771
|
const createPrimary = !table.getColumns().some(c => c.autoincrement && c.primary) || this.hasNonDefaultPrimaryKeyName(table);
|
|
768
772
|
if (createPrimary && primaryKey) {
|
|
769
|
-
const name = this.
|
|
773
|
+
const name = this.getPrimaryKeyConstraintPrefix(table, primaryKey);
|
|
770
774
|
sql += `, ${name}primary key (${primaryKey.columnNames.map(c => this.quote(c)).join(', ')})`;
|
|
771
775
|
}
|
|
772
776
|
sql += ')';
|
|
@@ -849,7 +853,7 @@ export class SchemaHelper {
|
|
|
849
853
|
const columns = index.columnNames.map(c => this.quote(c)).join(', ');
|
|
850
854
|
const defer = index.deferMode ? ` deferrable initially ${index.deferMode}` : '';
|
|
851
855
|
if (index.primary) {
|
|
852
|
-
const keyName = this.
|
|
856
|
+
const keyName = this.getPrimaryKeyConstraintPrefix(table, index);
|
|
853
857
|
return `alter table ${table.getQuotedName()} add ${keyName}primary key (${columns})${defer}`;
|
|
854
858
|
}
|
|
855
859
|
if (index.type === 'fulltext') {
|