@mikro-orm/sql 7.0.2-dev.9 → 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
@@ -2,13 +2,17 @@ import { Type, type TransformContext, type RawQueryFragment } from '@mikro-orm/c
2
2
  import type { BasePostgreSqlPlatform } from './BasePostgreSqlPlatform.js';
3
3
  type FullTextWeight = 'A' | 'B' | 'C' | 'D';
4
4
  export type WeightedFullTextValue = {
5
- [K in FullTextWeight]?: string | null;
5
+ [K in FullTextWeight]?: string | null;
6
6
  };
7
7
  export declare class FullTextType extends Type<string | WeightedFullTextValue, string | null | RawQueryFragment> {
8
- regconfig: string;
9
- constructor(regconfig?: string);
10
- compareAsType(): string;
11
- getColumnType(): string;
12
- convertToDatabaseValue(value: string | WeightedFullTextValue, platform: BasePostgreSqlPlatform, context?: TransformContext | boolean): string | null | RawQueryFragment;
8
+ regconfig: string;
9
+ constructor(regconfig?: string);
10
+ compareAsType(): string;
11
+ getColumnType(): string;
12
+ convertToDatabaseValue(
13
+ value: string | WeightedFullTextValue,
14
+ platform: BasePostgreSqlPlatform,
15
+ context?: TransformContext | boolean,
16
+ ): string | null | RawQueryFragment;
13
17
  }
14
18
  export {};
@@ -1,59 +1,59 @@
1
1
  import { raw, Type } from '@mikro-orm/core';
2
2
  export class FullTextType extends Type {
3
- regconfig;
4
- constructor(regconfig = 'simple') {
5
- super();
6
- this.regconfig = regconfig;
3
+ regconfig;
4
+ constructor(regconfig = 'simple') {
5
+ super();
6
+ this.regconfig = regconfig;
7
+ }
8
+ compareAsType() {
9
+ return 'any';
10
+ }
11
+ getColumnType() {
12
+ return 'tsvector';
13
+ }
14
+ // Use convertToDatabaseValue to prepare insert queries as this method has
15
+ // access to the raw JS value. Return Knex#raw to prevent QueryBuilderHelper#mapData
16
+ // from sanitizing the returned chaing of SQL functions.
17
+ convertToDatabaseValue(value, platform, context) {
18
+ // Don't convert to values from select queries to the to_tsvector notation
19
+ // these should be compared as string using a special oparator or function
20
+ // this behaviour is defined in Platform#getFullTextWhereClause.
21
+ // This is always a string.
22
+ if (typeof context === 'object' && context.fromQuery) {
23
+ return value;
7
24
  }
8
- compareAsType() {
9
- return 'any';
25
+ // Null values should not be processed
26
+ if (!value) {
27
+ return null;
10
28
  }
11
- getColumnType() {
12
- return 'tsvector';
13
- }
14
- // Use convertToDatabaseValue to prepare insert queries as this method has
15
- // access to the raw JS value. Return Knex#raw to prevent QueryBuilderHelper#mapData
16
- // from sanitizing the returned chaing of SQL functions.
17
- convertToDatabaseValue(value, platform, context) {
18
- // Don't convert to values from select queries to the to_tsvector notation
19
- // these should be compared as string using a special oparator or function
20
- // this behaviour is defined in Platform#getFullTextWhereClause.
21
- // This is always a string.
22
- if (typeof context === 'object' && context.fromQuery) {
23
- return value;
24
- }
25
- // Null values should not be processed
26
- if (!value) {
27
- return null;
29
+ // the object from that looks like { A: 'test data', B: 'test data2' ... }
30
+ // must be converted to
31
+ // setweight(to_tsvector(regconfig, value), A) || setweight(to_tsvector(regconfig, value), B)... etc
32
+ // use Knex#raw to do binding of the values sanitization of the boundvalues
33
+ // as we return a raw string which should not be sanitzed anymore
34
+ if (typeof value === 'object') {
35
+ const bindings = [];
36
+ const sqlParts = [];
37
+ for (const [weight, data] of Object.entries(value)) {
38
+ // Check whether the weight is valid according to Postgres,
39
+ // Postgres allows the weight to be upper and lowercase.
40
+ if (!['A', 'B', 'C', 'D'].includes(weight.toUpperCase())) {
41
+ throw new Error('Weight should be one of A, B, C, D.');
28
42
  }
29
- // the object from that looks like { A: 'test data', B: 'test data2' ... }
30
- // must be converted to
31
- // setweight(to_tsvector(regconfig, value), A) || setweight(to_tsvector(regconfig, value), B)... etc
32
- // use Knex#raw to do binding of the values sanitization of the boundvalues
33
- // as we return a raw string which should not be sanitzed anymore
34
- if (typeof value === 'object') {
35
- const bindings = [];
36
- const sqlParts = [];
37
- for (const [weight, data] of Object.entries(value)) {
38
- // Check whether the weight is valid according to Postgres,
39
- // Postgres allows the weight to be upper and lowercase.
40
- if (!['A', 'B', 'C', 'D'].includes(weight.toUpperCase())) {
41
- throw new Error('Weight should be one of A, B, C, D.');
42
- }
43
- // Ignore all values that are not a string
44
- if (typeof data === 'string') {
45
- sqlParts.push('setweight(to_tsvector(?, ?), ?)');
46
- bindings.push(this.regconfig, data, weight);
47
- }
48
- }
49
- // Return null if the object has no valid strings
50
- if (sqlParts.length === 0) {
51
- return null;
52
- }
53
- // Join all the `setweight` parts using the PostgreSQL tsvector `||` concatenation operator
54
- return raw(sqlParts.join(' || '), bindings);
43
+ // Ignore all values that are not a string
44
+ if (typeof data === 'string') {
45
+ sqlParts.push('setweight(to_tsvector(?, ?), ?)');
46
+ bindings.push(this.regconfig, data, weight);
55
47
  }
56
- // if it's not an object, it is expected to be string which does not have to be wrapped in setweight.
57
- return raw('to_tsvector(?, ?)', [this.regconfig, value]);
48
+ }
49
+ // Return null if the object has no valid strings
50
+ if (sqlParts.length === 0) {
51
+ return null;
52
+ }
53
+ // Join all the `setweight` parts using the PostgreSQL tsvector `||` concatenation operator
54
+ return raw(sqlParts.join(' || '), bindings);
58
55
  }
56
+ // if it's not an object, it is expected to be string which does not have to be wrapped in setweight.
57
+ return raw('to_tsvector(?, ?)', [this.regconfig, value]);
58
+ }
59
59
  }
@@ -1,8 +1,8 @@
1
1
  import { ExceptionConverter, type Dictionary, type DriverException } from '@mikro-orm/core';
2
2
  export declare class PostgreSqlExceptionConverter extends ExceptionConverter {
3
- /**
4
- * @see http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
5
- * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
6
- */
7
- convertException(exception: Error & Dictionary): DriverException;
3
+ /**
4
+ * @see http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
5
+ * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
6
+ */
7
+ convertException(exception: Error & Dictionary): DriverException;
8
8
  }
@@ -1,47 +1,59 @@
1
- import { DeadlockException, ExceptionConverter, ForeignKeyConstraintViolationException, InvalidFieldNameException, NonUniqueFieldNameException, NotNullConstraintViolationException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, CheckConstraintViolationException, } from '@mikro-orm/core';
1
+ import {
2
+ DeadlockException,
3
+ ExceptionConverter,
4
+ ForeignKeyConstraintViolationException,
5
+ InvalidFieldNameException,
6
+ NonUniqueFieldNameException,
7
+ NotNullConstraintViolationException,
8
+ SyntaxErrorException,
9
+ TableExistsException,
10
+ TableNotFoundException,
11
+ UniqueConstraintViolationException,
12
+ CheckConstraintViolationException,
13
+ } from '@mikro-orm/core';
2
14
  export class PostgreSqlExceptionConverter extends ExceptionConverter {
3
- /**
4
- * @see http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
5
- * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
6
- */
7
- convertException(exception) {
8
- if (exception.detail?.toString().trim()) {
9
- exception.message += '\n - detail: ' + exception.detail;
10
- }
11
- if (exception.hint?.toString().trim()) {
12
- exception.message += '\n - hint: ' + exception.hint;
13
- }
14
- /* v8 ignore next */
15
- switch (exception.code) {
16
- case '40001':
17
- case '40P01':
18
- return new DeadlockException(exception);
19
- case '0A000':
20
- // Foreign key constraint violations during a TRUNCATE operation
21
- // are considered "feature not supported" in PostgreSQL.
22
- if (exception.message.includes('truncate')) {
23
- return new ForeignKeyConstraintViolationException(exception);
24
- }
25
- break;
26
- case '23502':
27
- return new NotNullConstraintViolationException(exception);
28
- case '23503':
29
- return new ForeignKeyConstraintViolationException(exception);
30
- case '23505':
31
- return new UniqueConstraintViolationException(exception);
32
- case '23514':
33
- return new CheckConstraintViolationException(exception);
34
- case '42601':
35
- return new SyntaxErrorException(exception);
36
- case '42702':
37
- return new NonUniqueFieldNameException(exception);
38
- case '42703':
39
- return new InvalidFieldNameException(exception);
40
- case '42P01':
41
- return new TableNotFoundException(exception);
42
- case '42P07':
43
- return new TableExistsException(exception);
15
+ /**
16
+ * @see http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
17
+ * @see https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
18
+ */
19
+ convertException(exception) {
20
+ if (exception.detail?.toString().trim()) {
21
+ exception.message += '\n - detail: ' + exception.detail;
22
+ }
23
+ if (exception.hint?.toString().trim()) {
24
+ exception.message += '\n - hint: ' + exception.hint;
25
+ }
26
+ /* v8 ignore next */
27
+ switch (exception.code) {
28
+ case '40001':
29
+ case '40P01':
30
+ return new DeadlockException(exception);
31
+ case '0A000':
32
+ // Foreign key constraint violations during a TRUNCATE operation
33
+ // are considered "feature not supported" in PostgreSQL.
34
+ if (exception.message.includes('truncate')) {
35
+ return new ForeignKeyConstraintViolationException(exception);
44
36
  }
45
- return super.convertException(exception);
37
+ break;
38
+ case '23502':
39
+ return new NotNullConstraintViolationException(exception);
40
+ case '23503':
41
+ return new ForeignKeyConstraintViolationException(exception);
42
+ case '23505':
43
+ return new UniqueConstraintViolationException(exception);
44
+ case '23514':
45
+ return new CheckConstraintViolationException(exception);
46
+ case '42601':
47
+ return new SyntaxErrorException(exception);
48
+ case '42702':
49
+ return new NonUniqueFieldNameException(exception);
50
+ case '42703':
51
+ return new InvalidFieldNameException(exception);
52
+ case '42P01':
53
+ return new TableNotFoundException(exception);
54
+ case '42P07':
55
+ return new TableExistsException(exception);
46
56
  }
57
+ return super.convertException(exception);
58
+ }
47
59
  }
@@ -1,5 +1,5 @@
1
1
  import { NativeQueryBuilder } from '../../query/NativeQueryBuilder.js';
2
2
  /** @internal */
3
3
  export declare class PostgreSqlNativeQueryBuilder extends NativeQueryBuilder {
4
- protected compileTruncate(): void;
4
+ protected compileTruncate(): void;
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import { NativeQueryBuilder } from '../../query/NativeQueryBuilder.js';
2
2
  /** @internal */
3
3
  export class PostgreSqlNativeQueryBuilder extends NativeQueryBuilder {
4
- compileTruncate() {
5
- super.compileTruncate();
6
- this.parts.push('restart identity cascade');
7
- }
4
+ compileTruncate() {
5
+ super.compileTruncate();
6
+ this.parts.push('restart identity cascade');
7
+ }
8
8
  }
@@ -5,86 +5,106 @@ import type { CheckDef, Column, ForeignKey, IndexDef, Table, TableDifference } f
5
5
  import type { DatabaseSchema } from '../../schema/DatabaseSchema.js';
6
6
  import type { DatabaseTable } from '../../schema/DatabaseTable.js';
7
7
  export declare class PostgreSqlSchemaHelper extends SchemaHelper {
8
- static readonly DEFAULT_VALUES: {
9
- 'now()': string[];
10
- 'current_timestamp(?)': string[];
11
- "('now'::text)::timestamp(?) with time zone": string[];
12
- "('now'::text)::timestamp(?) without time zone": string[];
13
- 'null::character varying': string[];
14
- 'null::timestamp with time zone': string[];
15
- 'null::timestamp without time zone': string[];
16
- };
17
- getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string;
18
- getCreateDatabaseSQL(name: string): string;
19
- getListTablesSQL(): string;
20
- private getIgnoredViewsCondition;
21
- getListViewsSQL(): string;
22
- loadViews(schema: DatabaseSchema, connection: AbstractSqlConnection): Promise<void>;
23
- getListMaterializedViewsSQL(): string;
24
- loadMaterializedViews(schema: DatabaseSchema, connection: AbstractSqlConnection, schemaName?: string): Promise<void>;
25
- createMaterializedView(name: string, schema: string | undefined, definition: string, withData?: boolean): string;
26
- dropMaterializedViewIfExists(name: string, schema?: string): string;
27
- refreshMaterializedView(name: string, schema?: string, concurrently?: boolean): string;
28
- getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
29
- private getIgnoredNamespacesConditionSQL;
30
- loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>;
31
- getAllIndexes(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<IndexDef[]>>;
32
- /**
33
- * Parses column definitions from the full CREATE INDEX expression.
34
- * Since pg_get_indexdef(oid, col_num, true) doesn't include sort modifiers,
35
- * we extract them from the full expression instead.
36
- *
37
- * We use columnDefs (from individual pg_get_indexdef calls) as the source
38
- * of column names, and find their modifiers in the expression.
39
- */
40
- private parseIndexColumnsFromExpression;
41
- /**
42
- * Extracts the content inside parentheses starting at the given position.
43
- * Handles nested parentheses correctly.
44
- */
45
- private extractParenthesizedContent;
46
- getAllColumns(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, nativeEnums?: Dictionary<{
47
- name: string;
48
- schema?: string;
49
- items: string[];
50
- }>): Promise<Dictionary<Column[]>>;
51
- getAllChecks(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<CheckDef[]>>;
52
- getAllForeignKeys(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>): Promise<Dictionary<Dictionary<ForeignKey>>>;
53
- getNativeEnumDefinitions(connection: AbstractSqlConnection, schemas: string[]): Promise<Dictionary<{
54
- name: string;
55
- schema?: string;
56
- items: string[];
57
- }>>;
58
- getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string;
59
- getDropNativeEnumSQL(name: string, schema?: string): string;
60
- getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string;
61
- private getEnumDefinitions;
62
- createTableColumn(column: Column, table: DatabaseTable): string | undefined;
63
- getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
64
- castColumn(name: string, type: string): string;
65
- dropForeignKey(tableName: string, constraintName: string): string;
66
- getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
67
- private getAlterColumnAutoincrement;
68
- getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
69
- alterTableComment(table: DatabaseTable, comment?: string): string;
70
- normalizeDefaultValue(defaultValue: string, length: number): string | number;
71
- appendComments(table: DatabaseTable): string[];
72
- getDatabaseExistsSQL(name: string): string;
73
- getDatabaseNotExistsError(dbName: string): string;
74
- getManagementDbName(): string;
75
- disableForeignKeysSQL(): string;
76
- enableForeignKeysSQL(): string;
77
- getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string[];
78
- dropIndex(table: string, index: IndexDef, oldIndexName?: string): string;
79
- /**
80
- * Build the column list for a PostgreSQL index.
81
- */
82
- protected getIndexColumns(index: IndexDef): string;
83
- /**
84
- * PostgreSQL-specific index options like fill factor.
85
- */
86
- protected getCreateIndexSuffix(index: IndexDef): string;
87
- private getIndexesSQL;
88
- private getChecksSQL;
89
- inferLengthFromColumnType(type: string): number | undefined;
8
+ static readonly DEFAULT_VALUES: {
9
+ 'now()': string[];
10
+ 'current_timestamp(?)': string[];
11
+ "('now'::text)::timestamp(?) with time zone": string[];
12
+ "('now'::text)::timestamp(?) without time zone": string[];
13
+ 'null::character varying': string[];
14
+ 'null::timestamp with time zone': string[];
15
+ 'null::timestamp without time zone': string[];
16
+ };
17
+ getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string;
18
+ getCreateDatabaseSQL(name: string): string;
19
+ getListTablesSQL(): string;
20
+ private getIgnoredViewsCondition;
21
+ getListViewsSQL(): string;
22
+ loadViews(schema: DatabaseSchema, connection: AbstractSqlConnection): Promise<void>;
23
+ getListMaterializedViewsSQL(): string;
24
+ loadMaterializedViews(schema: DatabaseSchema, connection: AbstractSqlConnection, schemaName?: string): Promise<void>;
25
+ createMaterializedView(name: string, schema: string | undefined, definition: string, withData?: boolean): string;
26
+ dropMaterializedViewIfExists(name: string, schema?: string): string;
27
+ refreshMaterializedView(name: string, schema?: string, concurrently?: boolean): string;
28
+ getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
29
+ private getIgnoredNamespacesConditionSQL;
30
+ loadInformationSchema(
31
+ schema: DatabaseSchema,
32
+ connection: AbstractSqlConnection,
33
+ tables: Table[],
34
+ schemas?: string[],
35
+ ): Promise<void>;
36
+ getAllIndexes(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<IndexDef[]>>;
37
+ /**
38
+ * Parses column definitions from the full CREATE INDEX expression.
39
+ * Since pg_get_indexdef(oid, col_num, true) doesn't include sort modifiers,
40
+ * we extract them from the full expression instead.
41
+ *
42
+ * We use columnDefs (from individual pg_get_indexdef calls) as the source
43
+ * of column names, and find their modifiers in the expression.
44
+ */
45
+ private parseIndexColumnsFromExpression;
46
+ /**
47
+ * Extracts the content inside parentheses starting at the given position.
48
+ * Handles nested parentheses correctly.
49
+ */
50
+ private extractParenthesizedContent;
51
+ getAllColumns(
52
+ connection: AbstractSqlConnection,
53
+ tablesBySchemas: Map<string | undefined, Table[]>,
54
+ nativeEnums?: Dictionary<{
55
+ name: string;
56
+ schema?: string;
57
+ items: string[];
58
+ }>,
59
+ ): Promise<Dictionary<Column[]>>;
60
+ getAllChecks(
61
+ connection: AbstractSqlConnection,
62
+ tablesBySchemas: Map<string | undefined, Table[]>,
63
+ ): Promise<Dictionary<CheckDef[]>>;
64
+ getAllForeignKeys(
65
+ connection: AbstractSqlConnection,
66
+ tablesBySchemas: Map<string | undefined, Table[]>,
67
+ ): Promise<Dictionary<Dictionary<ForeignKey>>>;
68
+ getNativeEnumDefinitions(
69
+ connection: AbstractSqlConnection,
70
+ schemas: string[],
71
+ ): Promise<
72
+ Dictionary<{
73
+ name: string;
74
+ schema?: string;
75
+ items: string[];
76
+ }>
77
+ >;
78
+ getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string;
79
+ getDropNativeEnumSQL(name: string, schema?: string): string;
80
+ getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string;
81
+ private getEnumDefinitions;
82
+ createTableColumn(column: Column, table: DatabaseTable): string | undefined;
83
+ getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
84
+ castColumn(name: string, type: string): string;
85
+ dropForeignKey(tableName: string, constraintName: string): string;
86
+ getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
87
+ private getAlterColumnAutoincrement;
88
+ getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
89
+ alterTableComment(table: DatabaseTable, comment?: string): string;
90
+ normalizeDefaultValue(defaultValue: string, length: number): string | number;
91
+ appendComments(table: DatabaseTable): string[];
92
+ getDatabaseExistsSQL(name: string): string;
93
+ getDatabaseNotExistsError(dbName: string): string;
94
+ getManagementDbName(): string;
95
+ disableForeignKeysSQL(): string;
96
+ enableForeignKeysSQL(): string;
97
+ getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string[];
98
+ dropIndex(table: string, index: IndexDef, oldIndexName?: string): string;
99
+ /**
100
+ * Build the column list for a PostgreSQL index.
101
+ */
102
+ protected getIndexColumns(index: IndexDef): string;
103
+ /**
104
+ * PostgreSQL-specific index options like fill factor.
105
+ */
106
+ protected getCreateIndexSuffix(index: IndexDef): string;
107
+ private getIndexesSQL;
108
+ private getChecksSQL;
109
+ inferLengthFromColumnType(type: string): number | undefined;
90
110
  }