@mikro-orm/sql 7.0.16-dev.6 → 7.0.16-dev.8

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.
@@ -34,11 +34,9 @@ export declare class BaseMySqlPlatform extends AbstractSqlPlatform {
34
34
  getDefaultMappedType(type: string): Type<unknown>;
35
35
  isNumericColumn(mappedType: Type<unknown>): boolean;
36
36
  supportsUnsigned(): boolean;
37
- /**
38
- * Returns the default name of index for the given columns
39
- * cannot go past 64 character length for identifiers in MySQL
40
- */
41
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
37
+ /** MySQL/MariaDB identifier limit. */
38
+ getMaxIdentifierLength(): number;
39
+ getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence' | 'check'): string;
42
40
  getDefaultPrimaryName(tableName: string, columns: string[]): string;
43
41
  supportsCreatingFullTextIndex(): boolean;
44
42
  getFullTextWhereClause(): string;
@@ -1,4 +1,4 @@
1
- import { Utils, QueryOrder, DecimalType, DoubleType, } from '@mikro-orm/core';
1
+ import { QueryOrder, DecimalType, DoubleType, } from '@mikro-orm/core';
2
2
  import { MySqlSchemaHelper } from './MySqlSchemaHelper.js';
3
3
  import { MySqlExceptionConverter } from './MySqlExceptionConverter.js';
4
4
  import { AbstractSqlPlatform } from '../../AbstractSqlPlatform.js';
@@ -83,19 +83,15 @@ export class BaseMySqlPlatform extends AbstractSqlPlatform {
83
83
  supportsUnsigned() {
84
84
  return true;
85
85
  }
86
- /**
87
- * Returns the default name of index for the given columns
88
- * cannot go past 64 character length for identifiers in MySQL
89
- */
86
+ /** MySQL/MariaDB identifier limit. */
87
+ getMaxIdentifierLength() {
88
+ return 64;
89
+ }
90
90
  getIndexName(tableName, columns, type) {
91
91
  if (type === 'primary') {
92
92
  return this.getDefaultPrimaryName(tableName, columns);
93
93
  }
94
- const indexName = super.getIndexName(tableName, columns, type);
95
- if (indexName.length > 64) {
96
- return `${indexName.substring(0, 56 - type.length)}_${Utils.hash(indexName, 5)}_${type}`;
97
- }
98
- return indexName;
94
+ return super.getIndexName(tableName, columns, type);
99
95
  }
100
96
  getDefaultPrimaryName(tableName, columns) {
101
97
  return 'PRIMARY'; // https://dev.mysql.com/doc/refman/8.0/en/create-table.html#create-table-indexes-keys
@@ -93,11 +93,8 @@ export declare class BasePostgreSqlPlatform extends AbstractSqlPlatform {
93
93
  getDefaultMappedType(type: string): Type<unknown>;
94
94
  supportsSchemas(): boolean;
95
95
  getDefaultSchemaName(): string | undefined;
96
- /**
97
- * Returns the default name of index for the given columns
98
- * cannot go past 63 character length for identifiers in MySQL
99
- */
100
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
96
+ /** Postgres identifier limit (NAMEDATALEN - 1). */
97
+ getMaxIdentifierLength(): number;
101
98
  getDefaultPrimaryName(tableName: string, columns: string[]): string;
102
99
  /**
103
100
  * @inheritDoc
@@ -336,17 +336,9 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
336
336
  getDefaultSchemaName() {
337
337
  return 'public';
338
338
  }
339
- /**
340
- * Returns the default name of index for the given columns
341
- * cannot go past 63 character length for identifiers in MySQL
342
- */
343
- getIndexName(tableName, columns, type) {
344
- const indexName = super.getIndexName(tableName, columns, type);
345
- if (indexName.length > 63) {
346
- const suffix = type === 'primary' ? 'pkey' : type;
347
- return `${indexName.substring(0, 55 - type.length)}_${Utils.hash(indexName, 5)}_${suffix}`;
348
- }
349
- return indexName;
339
+ /** Postgres identifier limit (NAMEDATALEN - 1). */
340
+ getMaxIdentifierLength() {
341
+ return 63;
350
342
  }
351
343
  getDefaultPrimaryName(tableName, columns) {
352
344
  const indexName = `${tableName}_pkey`;
@@ -63,7 +63,7 @@ export declare class SqlitePlatform extends AbstractSqlPlatform {
63
63
  * including all Date properties, as we would be comparing Date object with timestamp.
64
64
  */
65
65
  processDateProperty(value: unknown): string | number | Date;
66
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
66
+ getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence' | 'check'): string;
67
67
  supportsDeferredUniqueConstraints(): boolean;
68
68
  /**
69
69
  * SQLite supports schemas via ATTACH DATABASE. Returns true when there are
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.0.16-dev.6",
3
+ "version": "7.0.16-dev.8",
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.0.15"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.0.16-dev.6"
56
+ "@mikro-orm/core": "7.0.16-dev.8"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"