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

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.
Files changed (87) hide show
  1. package/AbstractSqlConnection.d.ts +95 -47
  2. package/AbstractSqlConnection.js +240 -232
  3. package/AbstractSqlDriver.d.ts +412 -155
  4. package/AbstractSqlDriver.js +2062 -1937
  5. package/AbstractSqlPlatform.d.ts +84 -73
  6. package/AbstractSqlPlatform.js +163 -158
  7. package/PivotCollectionPersister.d.ts +33 -15
  8. package/PivotCollectionPersister.js +158 -160
  9. package/README.md +128 -294
  10. package/SqlEntityManager.d.ts +68 -20
  11. package/SqlEntityManager.js +54 -37
  12. package/SqlEntityRepository.d.ts +15 -14
  13. package/SqlEntityRepository.js +24 -23
  14. package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
  15. package/dialects/mssql/MsSqlNativeQueryBuilder.js +192 -194
  16. package/dialects/mysql/BaseMySqlPlatform.d.ts +64 -45
  17. package/dialects/mysql/BaseMySqlPlatform.js +134 -131
  18. package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
  19. package/dialects/mysql/MySqlExceptionConverter.js +91 -77
  20. package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
  21. package/dialects/mysql/MySqlNativeQueryBuilder.js +66 -69
  22. package/dialects/mysql/MySqlSchemaHelper.d.ts +39 -39
  23. package/dialects/mysql/MySqlSchemaHelper.js +327 -319
  24. package/dialects/oracledb/OracleDialect.d.ts +81 -52
  25. package/dialects/oracledb/OracleDialect.js +155 -149
  26. package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
  27. package/dialects/oracledb/OracleNativeQueryBuilder.js +232 -236
  28. package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +108 -105
  29. package/dialects/postgresql/BasePostgreSqlPlatform.js +351 -350
  30. package/dialects/postgresql/FullTextType.d.ts +10 -6
  31. package/dialects/postgresql/FullTextType.js +51 -51
  32. package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
  33. package/dialects/postgresql/PostgreSqlExceptionConverter.js +55 -43
  34. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
  35. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
  36. package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +102 -82
  37. package/dialects/postgresql/PostgreSqlSchemaHelper.js +711 -683
  38. package/dialects/sqlite/BaseSqliteConnection.d.ts +3 -5
  39. package/dialects/sqlite/BaseSqliteConnection.js +21 -19
  40. package/dialects/sqlite/NodeSqliteDialect.d.ts +1 -1
  41. package/dialects/sqlite/NodeSqliteDialect.js +23 -23
  42. package/dialects/sqlite/SqliteDriver.d.ts +1 -1
  43. package/dialects/sqlite/SqliteDriver.js +3 -3
  44. package/dialects/sqlite/SqliteExceptionConverter.d.ts +6 -6
  45. package/dialects/sqlite/SqliteExceptionConverter.js +67 -51
  46. package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
  47. package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
  48. package/dialects/sqlite/SqlitePlatform.d.ts +63 -72
  49. package/dialects/sqlite/SqlitePlatform.js +139 -139
  50. package/dialects/sqlite/SqliteSchemaHelper.d.ts +70 -60
  51. package/dialects/sqlite/SqliteSchemaHelper.js +533 -520
  52. package/package.json +4 -4
  53. package/plugin/index.d.ts +44 -35
  54. package/plugin/index.js +44 -36
  55. package/plugin/transformer.d.ts +117 -94
  56. package/plugin/transformer.js +890 -881
  57. package/query/ArrayCriteriaNode.d.ts +4 -4
  58. package/query/ArrayCriteriaNode.js +18 -18
  59. package/query/CriteriaNode.d.ts +35 -25
  60. package/query/CriteriaNode.js +133 -123
  61. package/query/CriteriaNodeFactory.d.ts +49 -6
  62. package/query/CriteriaNodeFactory.js +97 -94
  63. package/query/NativeQueryBuilder.d.ts +120 -117
  64. package/query/NativeQueryBuilder.js +484 -480
  65. package/query/ObjectCriteriaNode.d.ts +12 -12
  66. package/query/ObjectCriteriaNode.js +298 -282
  67. package/query/QueryBuilder.d.ts +1546 -904
  68. package/query/QueryBuilder.js +2270 -2145
  69. package/query/QueryBuilderHelper.d.ts +153 -72
  70. package/query/QueryBuilderHelper.js +1079 -1028
  71. package/query/ScalarCriteriaNode.d.ts +3 -3
  72. package/query/ScalarCriteriaNode.js +53 -46
  73. package/query/enums.d.ts +16 -14
  74. package/query/enums.js +16 -14
  75. package/query/raw.d.ts +16 -6
  76. package/query/raw.js +10 -10
  77. package/schema/DatabaseSchema.d.ts +73 -50
  78. package/schema/DatabaseSchema.js +331 -307
  79. package/schema/DatabaseTable.d.ts +96 -73
  80. package/schema/DatabaseTable.js +1012 -927
  81. package/schema/SchemaComparator.d.ts +58 -54
  82. package/schema/SchemaComparator.js +745 -719
  83. package/schema/SchemaHelper.d.ts +110 -80
  84. package/schema/SchemaHelper.js +676 -645
  85. package/schema/SqlSchemaGenerator.d.ts +79 -58
  86. package/schema/SqlSchemaGenerator.js +536 -501
  87. package/typings.d.ts +380 -266
@@ -1,66 +1,87 @@
1
- import { type ClearDatabaseOptions, type CreateSchemaOptions, type DropSchemaOptions, type EnsureDatabaseOptions, type EntityMetadata, type ISchemaGenerator, type MikroORM, type Options, type Transaction, type UpdateSchemaOptions } from '@mikro-orm/core';
1
+ import {
2
+ type ClearDatabaseOptions,
3
+ type CreateSchemaOptions,
4
+ type DropSchemaOptions,
5
+ type EnsureDatabaseOptions,
6
+ type EntityMetadata,
7
+ type ISchemaGenerator,
8
+ type MikroORM,
9
+ type Options,
10
+ type Transaction,
11
+ type UpdateSchemaOptions,
12
+ } from '@mikro-orm/core';
2
13
  import { AbstractSchemaGenerator } from '@mikro-orm/core/schema';
3
14
  import type { SchemaDifference } from '../typings.js';
4
15
  import { DatabaseSchema } from './DatabaseSchema.js';
5
16
  import type { AbstractSqlDriver } from '../AbstractSqlDriver.js';
6
17
  import type { SchemaHelper } from './SchemaHelper.js';
18
+ /** Generates and manages SQL database schemas based on entity metadata. Supports create, update, and drop operations. */
7
19
  export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<AbstractSqlDriver> implements ISchemaGenerator {
8
- protected readonly helper: SchemaHelper;
9
- protected readonly options: NonNullable<Options['schemaGenerator']>;
10
- protected lastEnsuredDatabase?: string;
11
- static register(orm: MikroORM): void;
12
- create(options?: CreateSchemaOptions): Promise<void>;
13
- /**
14
- * Returns true if the database was created.
15
- */
16
- ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
17
- getTargetSchema(schema?: string): DatabaseSchema;
18
- protected getOrderedMetadata(schema?: string): EntityMetadata[];
19
- getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
20
- drop(options?: DropSchemaOptions): Promise<void>;
21
- createNamespace(name: string): Promise<void>;
22
- dropNamespace(name: string): Promise<void>;
23
- clear(options?: ClearDatabaseOptions): Promise<void>;
24
- getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
25
- private getSchemaName;
26
- update(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<void>;
27
- getUpdateSchemaSQL(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<string>;
28
- getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<{
29
- up: string;
30
- down: string;
31
- }>;
32
- private prepareSchemaForComparison;
33
- diffToSQL(schemaDiff: SchemaDifference, options: {
34
- wrap?: boolean;
35
- safe?: boolean;
36
- dropTables?: boolean;
37
- schema?: string;
38
- }): string;
39
- /**
40
- * We need to drop foreign keys first for all tables to allow dropping PK constraints.
41
- */
42
- private preAlterTable;
43
- /**
44
- * creates new database and connects to it
45
- */
46
- createDatabase(name?: string, options?: {
47
- skipOnConnect?: boolean;
48
- }): Promise<void>;
49
- dropDatabase(name?: string): Promise<void>;
50
- execute(sql: string, options?: {
51
- wrap?: boolean;
52
- ctx?: Transaction;
53
- }): Promise<void>;
54
- dropTableIfExists(name: string, schema?: string): Promise<void>;
55
- private wrapSchema;
56
- private append;
57
- private matchName;
58
- private isTableSkipped;
59
- /**
60
- * Sorts views by their dependencies so that views depending on other views are created after their dependencies.
61
- * Uses topological sort based on view definition string matching.
62
- */
63
- private sortViewsByDependencies;
64
- private escapeRegExp;
20
+ protected readonly helper: SchemaHelper;
21
+ protected readonly options: NonNullable<Options['schemaGenerator']>;
22
+ protected lastEnsuredDatabase?: string;
23
+ static register(orm: MikroORM): void;
24
+ create(options?: CreateSchemaOptions): Promise<void>;
25
+ /**
26
+ * Returns true if the database was created.
27
+ */
28
+ ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
29
+ getTargetSchema(schema?: string): DatabaseSchema;
30
+ protected getOrderedMetadata(schema?: string): EntityMetadata[];
31
+ getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
32
+ drop(options?: DropSchemaOptions): Promise<void>;
33
+ createNamespace(name: string): Promise<void>;
34
+ dropNamespace(name: string): Promise<void>;
35
+ clear(options?: ClearDatabaseOptions): Promise<void>;
36
+ getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
37
+ private getSchemaName;
38
+ update(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<void>;
39
+ getUpdateSchemaSQL(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<string>;
40
+ getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions<DatabaseSchema>): Promise<{
41
+ up: string;
42
+ down: string;
43
+ }>;
44
+ private prepareSchemaForComparison;
45
+ diffToSQL(
46
+ schemaDiff: SchemaDifference,
47
+ options: {
48
+ wrap?: boolean;
49
+ safe?: boolean;
50
+ dropTables?: boolean;
51
+ schema?: string;
52
+ },
53
+ ): string;
54
+ /**
55
+ * We need to drop foreign keys first for all tables to allow dropping PK constraints.
56
+ */
57
+ private preAlterTable;
58
+ /**
59
+ * creates new database and connects to it
60
+ */
61
+ createDatabase(
62
+ name?: string,
63
+ options?: {
64
+ skipOnConnect?: boolean;
65
+ },
66
+ ): Promise<void>;
67
+ dropDatabase(name?: string): Promise<void>;
68
+ execute(
69
+ sql: string,
70
+ options?: {
71
+ wrap?: boolean;
72
+ ctx?: Transaction;
73
+ },
74
+ ): Promise<void>;
75
+ dropTableIfExists(name: string, schema?: string): Promise<void>;
76
+ private wrapSchema;
77
+ private append;
78
+ private matchName;
79
+ private isTableSkipped;
80
+ /**
81
+ * Sorts views by their dependencies so that views depending on other views are created after their dependencies.
82
+ * Uses topological sort based on view definition string matching.
83
+ */
84
+ private sortViewsByDependencies;
85
+ private escapeRegExp;
65
86
  }
66
87
  export { SqlSchemaGenerator as SchemaGenerator };