@mikro-orm/sql 7.0.17-dev.8 → 7.0.17

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.
@@ -150,36 +150,34 @@ export class MySqlSchemaHelper extends SchemaHelper {
150
150
  * MySQL requires collation to be specified as an expression: (column_name COLLATE collation_name)
151
151
  */
152
152
  getIndexColumns(index) {
153
- if (index.columns?.length) {
154
- return index.columns
155
- .map(col => {
156
- const quotedName = this.quote(col.name);
157
- // MySQL supports collation via expression: (column_name COLLATE collation_name)
158
- // When collation is specified, wrap in parentheses as an expression
159
- if (col.collation) {
160
- let expr = col.length ? `${quotedName}(${col.length})` : quotedName;
161
- expr = `(${expr} collate ${col.collation})`;
162
- // Sort order comes after the expression
163
- if (col.sort) {
164
- expr += ` ${col.sort}`;
165
- }
166
- return expr;
167
- }
168
- // Standard column definition without collation
169
- let colDef = quotedName;
170
- // MySQL supports prefix length
171
- if (col.length) {
172
- colDef += `(${col.length})`;
173
- }
174
- // MySQL supports sort order
153
+ return index.columnNames
154
+ .map(name => {
155
+ const col = index.columns?.find(c => c.name === name);
156
+ const quotedName = this.quote(name);
157
+ // MySQL supports collation via expression: (column_name COLLATE collation_name)
158
+ // When collation is specified, wrap in parentheses as an expression
159
+ if (col?.collation) {
160
+ let expr = col.length ? `${quotedName}(${col.length})` : quotedName;
161
+ expr = `(${expr} collate ${col.collation})`;
162
+ // Sort order comes after the expression
175
163
  if (col.sort) {
176
- colDef += ` ${col.sort}`;
164
+ expr += ` ${col.sort}`;
177
165
  }
178
- return colDef;
179
- })
180
- .join(', ');
181
- }
182
- return index.columnNames.map(c => this.quote(c)).join(', ');
166
+ return expr;
167
+ }
168
+ // Standard column definition without collation
169
+ let colDef = quotedName;
170
+ // MySQL supports prefix length
171
+ if (col?.length) {
172
+ colDef += `(${col.length})`;
173
+ }
174
+ // MySQL supports sort order
175
+ if (col?.sort) {
176
+ colDef += ` ${col.sort}`;
177
+ }
178
+ return colDef;
179
+ })
180
+ .join(', ');
183
181
  }
184
182
  /**
185
183
  * Append MySQL-specific index suffixes like INVISIBLE.
@@ -687,27 +687,25 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
687
687
  * Build the column list for a PostgreSQL index.
688
688
  */
689
689
  getIndexColumns(index) {
690
- if (index.columns?.length) {
691
- return index.columns
692
- .map(col => {
693
- let colDef = this.quote(col.name);
694
- // PostgreSQL supports collation with double quotes
695
- if (col.collation) {
696
- colDef += ` collate ${this.quote(col.collation)}`;
697
- }
698
- // PostgreSQL supports sort order
699
- if (col.sort) {
700
- colDef += ` ${col.sort}`;
701
- }
702
- // PostgreSQL supports NULLS FIRST/LAST
703
- if (col.nulls) {
704
- colDef += ` nulls ${col.nulls}`;
705
- }
706
- return colDef;
707
- })
708
- .join(', ');
709
- }
710
- return index.columnNames.map(c => this.quote(c)).join(', ');
690
+ return index.columnNames
691
+ .map(name => {
692
+ const col = index.columns?.find(c => c.name === name);
693
+ let colDef = this.quote(name);
694
+ // PostgreSQL supports collation with double quotes
695
+ if (col?.collation) {
696
+ colDef += ` collate ${this.quote(col.collation)}`;
697
+ }
698
+ // PostgreSQL supports sort order
699
+ if (col?.sort) {
700
+ colDef += ` ${col.sort}`;
701
+ }
702
+ // PostgreSQL supports NULLS FIRST/LAST
703
+ if (col?.nulls) {
704
+ colDef += ` nulls ${col.nulls}`;
705
+ }
706
+ return colDef;
707
+ })
708
+ .join(', ');
711
709
  }
712
710
  /**
713
711
  * PostgreSQL-specific index options like fill factor.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.0.17-dev.8",
3
+ "version": "7.0.17",
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,13 +47,13 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "kysely": "0.29.0"
50
+ "kysely": "0.29.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@mikro-orm/core": "^7.0.16"
53
+ "@mikro-orm/core": "^7.0.17"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.0.17-dev.8"
56
+ "@mikro-orm/core": "7.0.17"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -132,27 +132,25 @@ export class SchemaHelper {
132
132
  * Note: Prefix length is only supported by MySQL/MariaDB which override this method.
133
133
  */
134
134
  getIndexColumns(index) {
135
- if (index.columns?.length) {
136
- return index.columns
137
- .map(col => {
138
- let colDef = this.quote(col.name);
139
- // Collation comes after column name (SQLite syntax: column COLLATE name)
140
- if (col.collation) {
141
- colDef += ` collate ${col.collation}`;
142
- }
143
- // Sort order
144
- if (col.sort) {
145
- colDef += ` ${col.sort}`;
146
- }
147
- // NULLS ordering (PostgreSQL)
148
- if (col.nulls) {
149
- colDef += ` nulls ${col.nulls}`;
150
- }
151
- return colDef;
152
- })
153
- .join(', ');
154
- }
155
- return index.columnNames.map(c => this.quote(c)).join(', ');
135
+ return index.columnNames
136
+ .map(name => {
137
+ const col = index.columns?.find(c => c.name === name);
138
+ let colDef = this.quote(name);
139
+ // Collation comes after column name (SQLite syntax: column COLLATE name)
140
+ if (col?.collation) {
141
+ colDef += ` collate ${col.collation}`;
142
+ }
143
+ // Sort order
144
+ if (col?.sort) {
145
+ colDef += ` ${col.sort}`;
146
+ }
147
+ // NULLS ordering (PostgreSQL)
148
+ if (col?.nulls) {
149
+ colDef += ` nulls ${col.nulls}`;
150
+ }
151
+ return colDef;
152
+ })
153
+ .join(', ');
156
154
  }
157
155
  /** Returns SQL to drop an index. */
158
156
  getDropIndexSQL(tableName, index) {