@mikro-orm/postgresql 7.0.0-dev.99 → 7.0.0-rc.0

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.
@@ -1,9 +1,12 @@
1
- import type { Configuration, Constructor } from '@mikro-orm/core';
1
+ import { type Configuration, type Constructor, EntityManagerType } from '@mikro-orm/core';
2
2
  import { AbstractSqlDriver } from '@mikro-orm/sql';
3
3
  import { PostgreSqlConnection } from './PostgreSqlConnection.js';
4
4
  import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
5
+ import { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
5
6
  export declare class PostgreSqlDriver extends AbstractSqlDriver<PostgreSqlConnection> {
7
+ [EntityManagerType]: PostgreSqlEntityManager<this>;
6
8
  constructor(config: Configuration);
9
+ createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
7
10
  /** @inheritDoc */
8
11
  getORMClass(): Constructor<PostgreSqlMikroORM>;
9
12
  }
@@ -1,11 +1,18 @@
1
+ import { EntityManagerType } from '@mikro-orm/core';
1
2
  import { AbstractSqlDriver } from '@mikro-orm/sql';
2
3
  import { PostgreSqlConnection } from './PostgreSqlConnection.js';
3
4
  import { PostgreSqlPlatform } from './PostgreSqlPlatform.js';
4
5
  import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
6
+ import { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
5
7
  export class PostgreSqlDriver extends AbstractSqlDriver {
8
+ [EntityManagerType];
6
9
  constructor(config) {
7
10
  super(config, new PostgreSqlPlatform(), PostgreSqlConnection, ['kysely', 'pg']);
8
11
  }
12
+ createEntityManager(useContext) {
13
+ const EntityManagerClass = this.config.get('entityManager', PostgreSqlEntityManager);
14
+ return new EntityManagerClass(this.config, this, this.metadata, useContext);
15
+ }
9
16
  /** @inheritDoc */
10
17
  getORMClass() {
11
18
  return PostgreSqlMikroORM;
@@ -0,0 +1,18 @@
1
+ import { type EntityName } from '@mikro-orm/core';
2
+ import { SqlEntityManager } from '@mikro-orm/sql';
3
+ import type { PostgreSqlDriver } from './PostgreSqlDriver.js';
4
+ /**
5
+ * @inheritDoc
6
+ */
7
+ export declare class PostgreSqlEntityManager<Driver extends PostgreSqlDriver = PostgreSqlDriver> extends SqlEntityManager<Driver> {
8
+ /**
9
+ * Refreshes a materialized view.
10
+ *
11
+ * @param entityName - The entity name or class of the materialized view
12
+ * @param options - Optional settings
13
+ * @param options.concurrently - If true, refreshes the view concurrently (requires a unique index on the view)
14
+ */
15
+ refreshMaterializedView<Entity extends object>(entityName: EntityName<Entity>, options?: {
16
+ concurrently?: boolean;
17
+ }): Promise<void>;
18
+ }
@@ -0,0 +1,23 @@
1
+ import { SqlEntityManager } from '@mikro-orm/sql';
2
+ /**
3
+ * @inheritDoc
4
+ */
5
+ export class PostgreSqlEntityManager extends SqlEntityManager {
6
+ /**
7
+ * Refreshes a materialized view.
8
+ *
9
+ * @param entityName - The entity name or class of the materialized view
10
+ * @param options - Optional settings
11
+ * @param options.concurrently - If true, refreshes the view concurrently (requires a unique index on the view)
12
+ */
13
+ async refreshMaterializedView(entityName, options) {
14
+ const meta = this.getMetadata(entityName);
15
+ if (!meta.view || !meta.materialized) {
16
+ throw new Error(`Entity ${meta.className} is not a materialized view`);
17
+ }
18
+ const helper = this.getDriver().getPlatform().getSchemaHelper();
19
+ const schema = meta.schema ?? this.config.get('schema');
20
+ const sql = helper.refreshMaterializedView(meta.tableName, schema, options?.concurrently);
21
+ await this.execute(sql);
22
+ }
23
+ }
@@ -1,12 +1,12 @@
1
1
  import { type AnyEntity, type EntityClass, type EntitySchema, MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
2
- import type { SqlEntityManager } from '@mikro-orm/sql';
3
2
  import { PostgreSqlDriver } from './PostgreSqlDriver.js';
4
- export type PostgreSqlOptions<EM extends SqlEntityManager<PostgreSqlDriver> = SqlEntityManager<PostgreSqlDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Options<PostgreSqlDriver, EM, Entities>;
5
- export declare function definePostgreSqlConfig<EM extends SqlEntityManager<PostgreSqlDriver> = SqlEntityManager<PostgreSqlDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<PostgreSqlDriver, EM, Entities>): Options<PostgreSqlDriver, EM, Entities>;
3
+ import type { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
4
+ export type PostgreSqlOptions<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Options<PostgreSqlDriver, EM, Entities>;
5
+ export declare function definePostgreSqlConfig<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<PostgreSqlDriver, EM, Entities>): Options<PostgreSqlDriver, EM, Entities>;
6
6
  /**
7
7
  * @inheritDoc
8
8
  */
9
- export declare class PostgreSqlMikroORM<EM extends SqlEntityManager<PostgreSqlDriver> = SqlEntityManager<PostgreSqlDriver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<PostgreSqlDriver, EM, Entities> {
9
+ export declare class PostgreSqlMikroORM<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<PostgreSqlDriver, EM, Entities> {
10
10
  /**
11
11
  * @inheritDoc
12
12
  */
@@ -1,112 +1,12 @@
1
1
  import { type IPostgresInterval } from 'postgres-interval';
2
- import { type Configuration, type EntityProperty, type IsolationLevel, type SimpleColumnMeta, Type } from '@mikro-orm/core';
3
- import { AbstractSqlPlatform, type IndexDef, PostgreSqlNativeQueryBuilder } from '@mikro-orm/sql';
4
- import { PostgreSqlSchemaHelper } from './PostgreSqlSchemaHelper.js';
5
- import { PostgreSqlExceptionConverter } from './PostgreSqlExceptionConverter.js';
6
- export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
7
- protected readonly schemaHelper: PostgreSqlSchemaHelper;
8
- protected readonly exceptionConverter: PostgreSqlExceptionConverter;
9
- setConfig(config: Configuration): void;
10
- createNativeQueryBuilder(): PostgreSqlNativeQueryBuilder;
11
- usesReturningStatement(): boolean;
12
- usesCascadeStatement(): boolean;
13
- supportsNativeEnums(): boolean;
14
- usesEnumCheckConstraints(): boolean;
15
- supportsCustomPrimaryKeyNames(): boolean;
16
- getCurrentTimestampSQL(length: number): string;
17
- getDateTimeTypeDeclarationSQL(column: {
18
- length?: number;
19
- }): string;
20
- getDefaultDateTimeLength(): number;
2
+ import { BasePostgreSqlPlatform } from '@mikro-orm/sql';
3
+ export declare class PostgreSqlPlatform extends BasePostgreSqlPlatform {
21
4
  convertIntervalToJSValue(value: string): unknown;
22
5
  convertIntervalToDatabaseValue(value: IPostgresInterval): unknown;
23
- getTimeTypeDeclarationSQL(): string;
24
- getIntegerTypeDeclarationSQL(column: {
25
- length?: number;
26
- autoincrement?: boolean;
27
- generated?: string;
28
- }): string;
29
- getBigIntTypeDeclarationSQL(column: {
30
- autoincrement?: boolean;
31
- }): string;
32
- getTinyIntTypeDeclarationSQL(column: {
33
- length?: number;
34
- unsigned?: boolean;
35
- autoincrement?: boolean;
36
- }): string;
37
- getUuidTypeDeclarationSQL(column: {
38
- length?: number;
39
- }): string;
40
- getFullTextWhereClause(prop: EntityProperty): string;
41
- supportsCreatingFullTextIndex(): boolean;
42
- getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
43
- normalizeColumnType(type: string, options: {
44
- length?: number;
45
- precision?: number;
46
- scale?: number;
47
- autoincrement?: boolean;
48
- }): string;
49
- getMappedType(type: string): Type<unknown>;
50
- getRegExpOperator(val?: unknown, flags?: string): string;
51
- getRegExpValue(val: RegExp): {
52
- $re: string;
53
- $flags?: string;
54
- };
55
- isBigIntProperty(prop: EntityProperty): boolean;
56
- getArrayDeclarationSQL(): string;
57
- getFloatDeclarationSQL(): string;
58
- getDoubleDeclarationSQL(): string;
59
- getEnumTypeDeclarationSQL(column: {
60
- fieldNames: string[];
61
- items?: unknown[];
62
- nativeEnumName?: string;
63
- }): string;
64
- supportsMultipleStatements(): boolean;
65
- getBeginTransactionSQL(options?: {
66
- isolationLevel?: IsolationLevel;
67
- readOnly?: boolean;
68
- }): string[];
69
- marshallArray(values: string[]): string;
70
6
  unmarshallArray(value: string): string[];
71
- getVarcharTypeDeclarationSQL(column: {
72
- length?: number;
73
- }): string;
74
- getCharTypeDeclarationSQL(column: {
75
- length?: number;
76
- }): string;
77
- getIntervalTypeDeclarationSQL(column: {
78
- length?: number;
79
- }): string;
80
- getBlobDeclarationSQL(): string;
81
- getJsonDeclarationSQL(): string;
82
- getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string;
83
- getJsonIndexDefinition(index: IndexDef): string[];
84
- quoteIdentifier(id: string | {
85
- toString: () => string;
86
- }, quote?: string): string;
87
7
  escape(value: any): string;
88
- private pad;
89
- /** @internal */
90
- formatDate(date: Date): string;
91
- indexForeignKeys(): boolean;
92
- getDefaultMappedType(type: string): Type<unknown>;
93
- supportsSchemas(): boolean;
94
- getDefaultSchemaName(): string | undefined;
95
- /**
96
- * Returns the default name of index for the given columns
97
- * cannot go past 63 character length for identifiers in MySQL
98
- */
99
- getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
100
- getDefaultPrimaryName(tableName: string, columns: string[]): string;
101
- /**
102
- * @inheritDoc
103
- */
104
- castColumn(prop?: {
105
- columnTypes?: string[];
106
- }): string;
107
8
  /**
108
9
  * @inheritDoc
109
10
  */
110
11
  parseDate(value: string | number): Date;
111
- getDefaultClientUrl(): string;
112
12
  }
@@ -1,48 +1,9 @@
1
1
  import { Client } from 'pg';
2
+ import array from 'postgres-array';
2
3
  import parseDate from 'postgres-date';
3
4
  import PostgresInterval from 'postgres-interval';
4
- import { ALIAS_REPLACEMENT, ARRAY_OPERATORS, raw, RawQueryFragment, Type, Utils, } from '@mikro-orm/core';
5
- import { AbstractSqlPlatform, PostgreSqlNativeQueryBuilder } from '@mikro-orm/sql';
6
- import { PostgreSqlSchemaHelper } from './PostgreSqlSchemaHelper.js';
7
- import { PostgreSqlExceptionConverter } from './PostgreSqlExceptionConverter.js';
8
- import { FullTextType } from './types/FullTextType.js';
9
- export class PostgreSqlPlatform extends AbstractSqlPlatform {
10
- schemaHelper = new PostgreSqlSchemaHelper(this);
11
- exceptionConverter = new PostgreSqlExceptionConverter();
12
- setConfig(config) {
13
- if (config.get('forceUtcTimezone') == null) {
14
- config.set('forceUtcTimezone', true);
15
- }
16
- super.setConfig(config);
17
- }
18
- createNativeQueryBuilder() {
19
- return new PostgreSqlNativeQueryBuilder(this);
20
- }
21
- usesReturningStatement() {
22
- return true;
23
- }
24
- usesCascadeStatement() {
25
- return true;
26
- }
27
- supportsNativeEnums() {
28
- return true;
29
- }
30
- usesEnumCheckConstraints() {
31
- return true;
32
- }
33
- supportsCustomPrimaryKeyNames() {
34
- return true;
35
- }
36
- getCurrentTimestampSQL(length) {
37
- return `current_timestamp(${length})`;
38
- }
39
- getDateTimeTypeDeclarationSQL(column) {
40
- /* v8 ignore next */
41
- return 'timestamptz' + (column.length != null ? `(${column.length})` : '');
42
- }
43
- getDefaultDateTimeLength() {
44
- return 6;
45
- }
5
+ import { BasePostgreSqlPlatform, Utils } from '@mikro-orm/sql';
6
+ export class PostgreSqlPlatform extends BasePostgreSqlPlatform {
46
7
  convertIntervalToJSValue(value) {
47
8
  return PostgresInterval(value);
48
9
  }
@@ -52,215 +13,13 @@ export class PostgreSqlPlatform extends AbstractSqlPlatform {
52
13
  }
53
14
  return value;
54
15
  }
55
- getTimeTypeDeclarationSQL() {
56
- return 'time(0)';
57
- }
58
- getIntegerTypeDeclarationSQL(column) {
59
- if (column.autoincrement && !column.generated) {
60
- return 'serial';
61
- }
62
- return 'int';
63
- }
64
- getBigIntTypeDeclarationSQL(column) {
65
- /* v8 ignore next */
66
- if (column.autoincrement) {
67
- return `bigserial`;
68
- }
69
- return 'bigint';
70
- }
71
- getTinyIntTypeDeclarationSQL(column) {
72
- return 'smallint';
73
- }
74
- getUuidTypeDeclarationSQL(column) {
75
- return `uuid`;
76
- }
77
- getFullTextWhereClause(prop) {
78
- if (prop.customType instanceof FullTextType) {
79
- return `:column: @@ plainto_tsquery('${prop.customType.regconfig}', :query)`;
80
- }
81
- /* v8 ignore next */
82
- if (prop.columnTypes[0] === 'tsvector') {
83
- return `:column: @@ plainto_tsquery('simple', :query)`;
84
- }
85
- return `to_tsvector('simple', :column:) @@ plainto_tsquery('simple', :query)`;
86
- }
87
- supportsCreatingFullTextIndex() {
88
- return true;
89
- }
90
- getFullTextIndexExpression(indexName, schemaName, tableName, columns) {
91
- /* v8 ignore next */
92
- const quotedTableName = this.quoteIdentifier(schemaName ? `${schemaName}.${tableName}` : tableName);
93
- const quotedColumnNames = columns.map(c => this.quoteIdentifier(c.name));
94
- const quotedIndexName = this.quoteIdentifier(indexName);
95
- if (columns.length === 1 && columns[0].type === 'tsvector') {
96
- return `create index ${quotedIndexName} on ${quotedTableName} using gin(${quotedColumnNames[0]})`;
97
- }
98
- return `create index ${quotedIndexName} on ${quotedTableName} using gin(to_tsvector('simple', ${quotedColumnNames.join(` || ' ' || `)}))`;
99
- }
100
- normalizeColumnType(type, options) {
101
- const simpleType = this.extractSimpleType(type);
102
- if (['int', 'int4', 'integer'].includes(simpleType)) {
103
- return this.getIntegerTypeDeclarationSQL({});
104
- }
105
- if (['bigint', 'int8'].includes(simpleType)) {
106
- return this.getBigIntTypeDeclarationSQL({});
107
- }
108
- if (['smallint', 'int2'].includes(simpleType)) {
109
- return this.getSmallIntTypeDeclarationSQL({});
110
- }
111
- if (['boolean', 'bool'].includes(simpleType)) {
112
- return this.getBooleanTypeDeclarationSQL();
113
- }
114
- if (['varchar', 'character varying'].includes(simpleType)) {
115
- return this.getVarcharTypeDeclarationSQL(options);
116
- }
117
- if (['char', 'bpchar'].includes(simpleType)) {
118
- return this.getCharTypeDeclarationSQL(options);
119
- }
120
- if (['decimal', 'numeric'].includes(simpleType)) {
121
- return this.getDecimalTypeDeclarationSQL(options);
122
- }
123
- if (['interval'].includes(simpleType)) {
124
- return this.getIntervalTypeDeclarationSQL(options);
125
- }
126
- return super.normalizeColumnType(type, options);
127
- }
128
- getMappedType(type) {
129
- switch (this.extractSimpleType(type)) {
130
- case 'tsvector': return Type.getType(FullTextType);
131
- default: return super.getMappedType(type);
132
- }
133
- }
134
- getRegExpOperator(val, flags) {
135
- /* v8 ignore next */
136
- if ((val instanceof RegExp && val.flags.includes('i')) || flags?.includes('i')) {
137
- return '~*';
138
- }
139
- return '~';
140
- }
141
- /* v8 ignore next */
142
- getRegExpValue(val) {
143
- if (val.flags.includes('i')) {
144
- return { $re: val.source, $flags: val.flags };
145
- }
146
- return { $re: val.source };
147
- }
148
- isBigIntProperty(prop) {
149
- return super.isBigIntProperty(prop) || (['bigserial', 'int8'].includes(prop.columnTypes?.[0]));
150
- }
151
- getArrayDeclarationSQL() {
152
- return 'text[]';
153
- }
154
- getFloatDeclarationSQL() {
155
- return 'real';
156
- }
157
- getDoubleDeclarationSQL() {
158
- return 'double precision';
159
- }
160
- getEnumTypeDeclarationSQL(column) {
161
- /* v8 ignore next */
162
- if (column.nativeEnumName) {
163
- return column.nativeEnumName;
164
- }
165
- if (column.items?.every(item => typeof item === 'string')) {
166
- return 'text';
167
- }
168
- return `smallint`;
169
- }
170
- supportsMultipleStatements() {
171
- return true;
172
- }
173
- getBeginTransactionSQL(options) {
174
- if (options?.isolationLevel || options?.readOnly) {
175
- let sql = 'start transaction';
176
- sql += options.isolationLevel ? ` isolation level ${options.isolationLevel}` : '';
177
- sql += options.readOnly ? ` read only` : '';
178
- return [sql];
179
- }
180
- return ['begin'];
181
- }
182
- marshallArray(values) {
183
- const quote = (v) => v === '' || v.match(/["{},\\]/) ? JSON.stringify(v) : v;
184
- return `{${values.map(v => quote('' + v)).join(',')}}`;
185
- }
186
16
  unmarshallArray(value) {
187
- if (value === '{}') {
188
- return [];
189
- }
190
- return value.substring(1, value.length - 1).split(',').map(v => {
191
- if (v === `""`) {
192
- return '';
193
- }
194
- if (v.match(/"(.*)"/)) {
195
- return v.substring(1, v.length - 1).replaceAll('\\"', '"');
196
- }
197
- return v;
198
- });
199
- }
200
- getVarcharTypeDeclarationSQL(column) {
201
- if (column.length === -1) {
202
- return 'varchar';
203
- }
204
- return super.getVarcharTypeDeclarationSQL(column);
205
- }
206
- getCharTypeDeclarationSQL(column) {
207
- if (column.length === -1) {
208
- return 'char';
209
- }
210
- return super.getCharTypeDeclarationSQL(column);
211
- }
212
- getIntervalTypeDeclarationSQL(column) {
213
- return 'interval' + (column.length != null ? `(${column.length})` : '');
214
- }
215
- getBlobDeclarationSQL() {
216
- return 'bytea';
217
- }
218
- getJsonDeclarationSQL() {
219
- return 'jsonb';
220
- }
221
- getSearchJsonPropertyKey(path, type, aliased, value) {
222
- const first = path.shift();
223
- const last = path.pop();
224
- const root = this.quoteIdentifier(aliased ? `${ALIAS_REPLACEMENT}.${first}` : first);
225
- type = typeof type === 'string' ? this.getMappedType(type).runtimeType : String(type);
226
- const types = {
227
- number: 'float8',
228
- bigint: 'int8',
229
- boolean: 'bool',
230
- };
231
- const cast = (key) => raw(type in types ? `(${key})::${types[type]}` : key);
232
- let lastOperator = '->>';
233
- // force `->` for operator payloads with array values
234
- if (Utils.isPlainObject(value) && Object.keys(value).every(key => ARRAY_OPERATORS.includes(key) && Array.isArray(value[key]))) {
235
- lastOperator = '->';
236
- }
237
- if (path.length === 0) {
238
- return cast(`${root}${lastOperator}'${last}'`);
239
- }
240
- return cast(`${root}->${path.map(a => this.quoteValue(a)).join('->')}${lastOperator}'${last}'`);
241
- }
242
- getJsonIndexDefinition(index) {
243
- return index.columnNames
244
- .map(column => {
245
- if (!column.includes('.')) {
246
- return column;
247
- }
248
- const path = column.split('.');
249
- const first = path.shift();
250
- const last = path.pop();
251
- if (path.length === 0) {
252
- return `(${this.quoteIdentifier(first)}->>${this.quoteValue(last)})`;
253
- }
254
- return `(${this.quoteIdentifier(first)}->${path.map(c => this.quoteValue(c)).join('->')}->>${this.quoteValue(last)})`;
255
- });
256
- }
257
- quoteIdentifier(id, quote = '"') {
258
- if (RawQueryFragment.isKnownFragment(id)) {
259
- return super.quoteIdentifier(id);
260
- }
261
- return `${quote}${id.toString().replace('.', `${quote}.${quote}`)}${quote}`;
17
+ return array.parse(value);
262
18
  }
263
19
  escape(value) {
20
+ if (typeof value === 'bigint') {
21
+ value = value.toString();
22
+ }
264
23
  if (typeof value === 'string') {
265
24
  return Client.prototype.escapeLiteral(value);
266
25
  }
@@ -273,104 +32,7 @@ export class PostgreSqlPlatform extends AbstractSqlPlatform {
273
32
  if (Array.isArray(value)) {
274
33
  return value.map(v => this.escape(v)).join(', ');
275
34
  }
276
- return super.escape(value);
277
- }
278
- pad(number, digits) {
279
- return String(number).padStart(digits, '0');
280
- }
281
- /** @internal */
282
- formatDate(date) {
283
- if (this.timezone === 'Z') {
284
- return date.toISOString();
285
- }
286
- let offset = -date.getTimezoneOffset();
287
- let year = date.getFullYear();
288
- const isBCYear = year < 1;
289
- /* v8 ignore next */
290
- if (isBCYear) {
291
- year = Math.abs(year) + 1;
292
- }
293
- const datePart = `${this.pad(year, 4)}-${this.pad(date.getMonth() + 1, 2)}-${this.pad(date.getDate(), 2)}`;
294
- const timePart = `${this.pad(date.getHours(), 2)}:${this.pad(date.getMinutes(), 2)}:${this.pad(date.getSeconds(), 2)}.${this.pad(date.getMilliseconds(), 3)}`;
295
- let ret = `${datePart}T${timePart}`;
296
- /* v8 ignore next */
297
- if (offset < 0) {
298
- ret += '-';
299
- offset *= -1;
300
- }
301
- else {
302
- ret += '+';
303
- }
304
- ret += this.pad(Math.floor(offset / 60), 2) + ':' + this.pad(offset % 60, 2);
305
- /* v8 ignore next */
306
- if (isBCYear) {
307
- ret += ' BC';
308
- }
309
- return ret;
310
- }
311
- indexForeignKeys() {
312
- return false;
313
- }
314
- getDefaultMappedType(type) {
315
- const normalizedType = this.extractSimpleType(type);
316
- const map = {
317
- 'int2': 'smallint',
318
- 'smallserial': 'smallint',
319
- 'int': 'integer',
320
- 'int4': 'integer',
321
- 'serial': 'integer',
322
- 'serial4': 'integer',
323
- 'int8': 'bigint',
324
- 'bigserial': 'bigint',
325
- 'serial8': 'bigint',
326
- 'numeric': 'decimal',
327
- 'bool': 'boolean',
328
- 'real': 'float',
329
- 'float4': 'float',
330
- 'float8': 'double',
331
- 'timestamp': 'datetime',
332
- 'timestamptz': 'datetime',
333
- 'bytea': 'blob',
334
- 'jsonb': 'json',
335
- 'character varying': 'varchar',
336
- 'bpchar': 'character',
337
- };
338
- return super.getDefaultMappedType(map[normalizedType] ?? type);
339
- }
340
- supportsSchemas() {
341
- return true;
342
- }
343
- getDefaultSchemaName() {
344
- return 'public';
345
- }
346
- /**
347
- * Returns the default name of index for the given columns
348
- * cannot go past 63 character length for identifiers in MySQL
349
- */
350
- getIndexName(tableName, columns, type) {
351
- const indexName = super.getIndexName(tableName, columns, type);
352
- if (indexName.length > 63) {
353
- const suffix = type === 'primary' ? 'pkey' : type;
354
- return `${indexName.substring(0, 55 - type.length)}_${Utils.hash(indexName, 5)}_${suffix}`;
355
- }
356
- return indexName;
357
- }
358
- getDefaultPrimaryName(tableName, columns) {
359
- const indexName = `${tableName}_pkey`;
360
- if (indexName.length > 63) {
361
- return `${indexName.substring(0, 55 - 'pkey'.length)}_${Utils.hash(indexName, 5)}_pkey`;
362
- }
363
- return indexName;
364
- }
365
- /**
366
- * @inheritDoc
367
- */
368
- castColumn(prop) {
369
- switch (prop?.columnTypes?.[0]) {
370
- case this.getUuidTypeDeclarationSQL({}): return '::text';
371
- case this.getBooleanTypeDeclarationSQL(): return '::int';
372
- default: return '';
373
- }
35
+ return value;
374
36
  }
375
37
  /**
376
38
  * @inheritDoc
@@ -392,7 +54,4 @@ export class PostgreSqlPlatform extends AbstractSqlPlatform {
392
54
  }
393
55
  return parsed;
394
56
  }
395
- getDefaultClientUrl() {
396
- return 'postgresql://postgres@127.0.0.1:5432';
397
- }
398
57
  }
package/index.d.ts CHANGED
@@ -2,8 +2,6 @@ export * from '@mikro-orm/sql';
2
2
  export * from './PostgreSqlConnection.js';
3
3
  export * from './PostgreSqlDriver.js';
4
4
  export * from './PostgreSqlPlatform.js';
5
- export * from './PostgreSqlSchemaHelper.js';
6
- export * from './PostgreSqlExceptionConverter.js';
7
- export * from './types/index.js';
5
+ export { PostgreSqlEntityManager as EntityManager } from './PostgreSqlEntityManager.js';
8
6
  export { PostgreSqlMikroORM as MikroORM, type PostgreSqlOptions as Options, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
9
7
  export { raw } from './raw.js';
package/index.js CHANGED
@@ -2,8 +2,6 @@ export * from '@mikro-orm/sql';
2
2
  export * from './PostgreSqlConnection.js';
3
3
  export * from './PostgreSqlDriver.js';
4
4
  export * from './PostgreSqlPlatform.js';
5
- export * from './PostgreSqlSchemaHelper.js';
6
- export * from './PostgreSqlExceptionConverter.js';
7
- export * from './types/index.js';
5
+ export { PostgreSqlEntityManager as EntityManager } from './PostgreSqlEntityManager.js';
8
6
  export { PostgreSqlMikroORM as MikroORM, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
9
7
  export { raw } from './raw.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/postgresql",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.99",
4
+ "version": "7.0.0-rc.0",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -41,7 +41,7 @@
41
41
  "node": ">= 22.17.0"
42
42
  },
43
43
  "scripts": {
44
- "build": "yarn clean && yarn compile && yarn copy",
44
+ "build": "yarn compile && yarn copy",
45
45
  "clean": "yarn run -T rimraf ./dist",
46
46
  "compile": "yarn run -T tsc -p tsconfig.build.json",
47
47
  "copy": "node ../../scripts/copy.mjs"
@@ -50,19 +50,18 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/sql": "7.0.0-dev.99",
54
- "pg": "8.16.3",
55
- "pg-cursor": "2.15.3",
53
+ "@mikro-orm/sql": "7.0.0-rc.0",
54
+ "kysely": "0.28.11",
55
+ "pg": "8.18.0",
56
+ "pg-cursor": "2.17.0",
56
57
  "postgres-array": "3.0.4",
57
58
  "postgres-date": "2.1.0",
58
59
  "postgres-interval": "4.0.2"
59
60
  },
60
61
  "devDependencies": {
61
- "@mikro-orm/core": "^6.6.2",
62
- "kysely": "0.28.8"
62
+ "@mikro-orm/core": "^6.6.4"
63
63
  },
64
64
  "peerDependencies": {
65
- "@mikro-orm/core": "7.0.0-dev.99",
66
- "kysely": "*"
65
+ "@mikro-orm/core": "7.0.0-rc.0"
67
66
  }
68
67
  }