@mikro-orm/sql 7.1.0-dev.35 → 7.1.0-dev.37

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.
@@ -35,11 +35,9 @@ export declare class BaseMySqlPlatform extends AbstractSqlPlatform {
35
35
  getDefaultMappedType(type: string): Type<unknown>;
36
36
  isNumericColumn(mappedType: Type<unknown>): boolean;
37
37
  supportsUnsigned(): boolean;
38
- /**
39
- * Returns the default name of index for the given columns
40
- * cannot go past 64 character length for identifiers in MySQL
41
- */
42
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
38
+ /** MySQL/MariaDB identifier limit. */
39
+ getMaxIdentifierLength(): number;
40
+ getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence' | 'check'): string;
43
41
  getDefaultPrimaryName(tableName: string, columns: string[]): string;
44
42
  supportsCreatingFullTextIndex(): boolean;
45
43
  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';
@@ -86,19 +86,15 @@ export class BaseMySqlPlatform extends AbstractSqlPlatform {
86
86
  supportsUnsigned() {
87
87
  return true;
88
88
  }
89
- /**
90
- * Returns the default name of index for the given columns
91
- * cannot go past 64 character length for identifiers in MySQL
92
- */
89
+ /** MySQL/MariaDB identifier limit. */
90
+ getMaxIdentifierLength() {
91
+ return 64;
92
+ }
93
93
  getIndexName(tableName, columns, type) {
94
94
  if (type === 'primary') {
95
95
  return this.getDefaultPrimaryName(tableName, columns);
96
96
  }
97
- const indexName = super.getIndexName(tableName, columns, type);
98
- if (indexName.length > 64) {
99
- return `${indexName.substring(0, 56 - type.length)}_${Utils.hash(indexName, 5)}_${type}`;
100
- }
101
- return indexName;
97
+ return super.getIndexName(tableName, columns, type);
102
98
  }
103
99
  getDefaultPrimaryName(tableName, columns) {
104
100
  return 'PRIMARY'; // https://dev.mysql.com/doc/refman/8.0/en/create-table.html#create-table-indexes-keys
@@ -100,11 +100,8 @@ export declare class BasePostgreSqlPlatform extends AbstractSqlPlatform {
100
100
  getDefaultMappedType(type: string): Type<unknown>;
101
101
  supportsSchemas(): boolean;
102
102
  getDefaultSchemaName(): string | undefined;
103
- /**
104
- * Returns the default name of index for the given columns
105
- * cannot go past 63 character length for identifiers in MySQL
106
- */
107
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
103
+ /** Postgres identifier limit (NAMEDATALEN - 1). */
104
+ getMaxIdentifierLength(): number;
108
105
  getDefaultPrimaryName(tableName: string, columns: string[]): string;
109
106
  /**
110
107
  * @inheritDoc
@@ -383,17 +383,9 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
383
383
  getDefaultSchemaName() {
384
384
  return 'public';
385
385
  }
386
- /**
387
- * Returns the default name of index for the given columns
388
- * cannot go past 63 character length for identifiers in MySQL
389
- */
390
- getIndexName(tableName, columns, type) {
391
- const indexName = super.getIndexName(tableName, columns, type);
392
- if (indexName.length > 63) {
393
- const suffix = type === 'primary' ? 'pkey' : type;
394
- return `${indexName.substring(0, 55 - type.length)}_${Utils.hash(indexName, 5)}_${suffix}`;
395
- }
396
- return indexName;
386
+ /** Postgres identifier limit (NAMEDATALEN - 1). */
387
+ getMaxIdentifierLength() {
388
+ return 63;
397
389
  }
398
390
  getDefaultPrimaryName(tableName, columns) {
399
391
  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.1.0-dev.35",
3
+ "version": "7.1.0-dev.37",
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.1.0-dev.35"
56
+ "@mikro-orm/core": "7.1.0-dev.37"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"