@mikro-orm/sql 7.1.0-dev.41 → 7.1.0-dev.42

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.
@@ -188,36 +188,34 @@ export class MySqlSchemaHelper extends SchemaHelper {
188
188
  if (index.where) {
189
189
  return this.emulatePartialIndexColumns(index);
190
190
  }
191
- if (index.columns?.length) {
192
- return index.columns
193
- .map(col => {
194
- const quotedName = this.quote(col.name);
195
- // MySQL supports collation via expression: (column_name COLLATE collation_name)
196
- // When collation is specified, wrap in parentheses as an expression
197
- if (col.collation) {
198
- let expr = col.length ? `${quotedName}(${col.length})` : quotedName;
199
- expr = `(${expr} collate ${col.collation})`;
200
- // Sort order comes after the expression
201
- if (col.sort) {
202
- expr += ` ${col.sort}`;
203
- }
204
- return expr;
205
- }
206
- // Standard column definition without collation
207
- let colDef = quotedName;
208
- // MySQL supports prefix length
209
- if (col.length) {
210
- colDef += `(${col.length})`;
211
- }
212
- // MySQL supports sort order
191
+ return index.columnNames
192
+ .map(name => {
193
+ const col = index.columns?.find(c => c.name === name);
194
+ const quotedName = this.quote(name);
195
+ // MySQL supports collation via expression: (column_name COLLATE collation_name)
196
+ // When collation is specified, wrap in parentheses as an expression
197
+ if (col?.collation) {
198
+ let expr = col.length ? `${quotedName}(${col.length})` : quotedName;
199
+ expr = `(${expr} collate ${col.collation})`;
200
+ // Sort order comes after the expression
213
201
  if (col.sort) {
214
- colDef += ` ${col.sort}`;
202
+ expr += ` ${col.sort}`;
215
203
  }
216
- return colDef;
217
- })
218
- .join(', ');
219
- }
220
- return index.columnNames.map(c => this.quote(c)).join(', ');
204
+ return expr;
205
+ }
206
+ // Standard column definition without collation
207
+ let colDef = quotedName;
208
+ // MySQL supports prefix length
209
+ if (col?.length) {
210
+ colDef += `(${col.length})`;
211
+ }
212
+ // MySQL supports sort order
213
+ if (col?.sort) {
214
+ colDef += ` ${col.sort}`;
215
+ }
216
+ return colDef;
217
+ })
218
+ .join(', ');
221
219
  }
222
220
  /**
223
221
  * Append MySQL-specific index suffixes like INVISIBLE.
@@ -911,27 +911,25 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
911
911
  * Build the column list for a PostgreSQL index.
912
912
  */
913
913
  getIndexColumns(index) {
914
- if (index.columns?.length) {
915
- return index.columns
916
- .map(col => {
917
- let colDef = this.quote(col.name);
918
- // PostgreSQL supports collation with double quotes
919
- if (col.collation) {
920
- colDef += ` collate ${this.quote(col.collation)}`;
921
- }
922
- // PostgreSQL supports sort order
923
- if (col.sort) {
924
- colDef += ` ${col.sort}`;
925
- }
926
- // PostgreSQL supports NULLS FIRST/LAST
927
- if (col.nulls) {
928
- colDef += ` nulls ${col.nulls}`;
929
- }
930
- return colDef;
931
- })
932
- .join(', ');
933
- }
934
- return index.columnNames.map(c => this.quote(c)).join(', ');
914
+ return index.columnNames
915
+ .map(name => {
916
+ const col = index.columns?.find(c => c.name === name);
917
+ let colDef = this.quote(name);
918
+ // PostgreSQL supports collation with double quotes
919
+ if (col?.collation) {
920
+ colDef += ` collate ${this.quote(col.collation)}`;
921
+ }
922
+ // PostgreSQL supports sort order
923
+ if (col?.sort) {
924
+ colDef += ` ${col.sort}`;
925
+ }
926
+ // PostgreSQL supports NULLS FIRST/LAST
927
+ if (col?.nulls) {
928
+ colDef += ` nulls ${col.nulls}`;
929
+ }
930
+ return colDef;
931
+ })
932
+ .join(', ');
935
933
  }
936
934
  /**
937
935
  * 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.1.0-dev.41",
3
+ "version": "7.1.0-dev.42",
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.1.0-dev.41"
56
+ "@mikro-orm/core": "7.1.0-dev.42"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -312,27 +312,25 @@ export class SchemaHelper {
312
312
  * Note: Prefix length is only supported by MySQL/MariaDB which override this method.
313
313
  */
314
314
  getIndexColumns(index) {
315
- if (index.columns?.length) {
316
- return index.columns
317
- .map(col => {
318
- let colDef = this.quote(col.name);
319
- // Collation comes after column name (SQLite syntax: column COLLATE name)
320
- if (col.collation) {
321
- colDef += ` collate ${col.collation}`;
322
- }
323
- // Sort order
324
- if (col.sort) {
325
- colDef += ` ${col.sort}`;
326
- }
327
- // NULLS ordering (PostgreSQL)
328
- if (col.nulls) {
329
- colDef += ` nulls ${col.nulls}`;
330
- }
331
- return colDef;
332
- })
333
- .join(', ');
334
- }
335
- return index.columnNames.map(c => this.quote(c)).join(', ');
315
+ return index.columnNames
316
+ .map(name => {
317
+ const col = index.columns?.find(c => c.name === name);
318
+ let colDef = this.quote(name);
319
+ // Collation comes after column name (SQLite syntax: column COLLATE name)
320
+ if (col?.collation) {
321
+ colDef += ` collate ${col.collation}`;
322
+ }
323
+ // Sort order
324
+ if (col?.sort) {
325
+ colDef += ` ${col.sort}`;
326
+ }
327
+ // NULLS ordering (PostgreSQL)
328
+ if (col?.nulls) {
329
+ colDef += ` nulls ${col.nulls}`;
330
+ }
331
+ return colDef;
332
+ })
333
+ .join(', ');
336
334
  }
337
335
  /** Returns SQL to drop an index. */
338
336
  getDropIndexSQL(tableName, index) {