@mikro-orm/postgresql 7.0.0-dev.1 → 7.0.0-dev.100

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,6 +1,6 @@
1
1
  import { type PoolConfig } from 'pg';
2
2
  import { PostgresDialect } from 'kysely';
3
- import { AbstractSqlConnection } from '@mikro-orm/knex';
3
+ import { AbstractSqlConnection } from '@mikro-orm/sql';
4
4
  export declare class PostgreSqlConnection extends AbstractSqlConnection {
5
5
  createKyselyDialect(overrides: PoolConfig): PostgresDialect;
6
6
  mapOptions(overrides: PoolConfig): PoolConfig;
@@ -1,30 +1,24 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PostgreSqlConnection = void 0;
7
- const type_overrides_1 = __importDefault(require("pg/lib/type-overrides"));
8
- const pg_1 = require("pg");
9
- const kysely_1 = require("kysely");
10
- const postgres_array_1 = __importDefault(require("postgres-array"));
11
- const knex_1 = require("@mikro-orm/knex");
12
- class PostgreSqlConnection extends knex_1.AbstractSqlConnection {
1
+ import { Pool, TypeOverrides } from 'pg';
2
+ import Cursor from 'pg-cursor';
3
+ import { PostgresDialect } from 'kysely';
4
+ import array from 'postgres-array';
5
+ import { AbstractSqlConnection, Utils } from '@mikro-orm/sql';
6
+ export class PostgreSqlConnection extends AbstractSqlConnection {
13
7
  createKyselyDialect(overrides) {
14
8
  const options = this.mapOptions(overrides);
15
- return new kysely_1.PostgresDialect({
16
- pool: new pg_1.Pool(options),
9
+ return new PostgresDialect({
10
+ pool: new Pool(options),
11
+ cursor: Cursor,
17
12
  onCreateConnection: this.options.onCreateConnection ?? this.config.get('onCreateConnection'),
18
13
  });
19
14
  }
20
15
  mapOptions(overrides) {
21
16
  const ret = { ...this.getConnectionOptions() };
22
17
  const pool = this.config.get('pool');
23
- knex_1.Utils.defaultValue(ret, 'min', pool?.min);
24
- knex_1.Utils.defaultValue(ret, 'max', pool?.max);
25
- knex_1.Utils.defaultValue(ret, 'idleTimeoutMillis', pool?.idleTimeoutMillis);
18
+ Utils.defaultValue(ret, 'max', pool?.max);
19
+ Utils.defaultValue(ret, 'idleTimeoutMillis', pool?.idleTimeoutMillis);
26
20
  // use `select typname, oid, typarray from pg_type order by oid` to get the list of OIDs
27
- const types = new type_overrides_1.default();
21
+ const types = new TypeOverrides();
28
22
  [
29
23
  1082, // date
30
24
  1114, // timestamp
@@ -36,9 +30,8 @@ class PostgreSqlConnection extends knex_1.AbstractSqlConnection {
36
30
  1115, // timestamp[]
37
31
  1185, // timestamptz[]
38
32
  1187, // interval[]
39
- ].forEach(oid => types.setTypeParser(oid, str => postgres_array_1.default.parse(str)));
33
+ ].forEach(oid => types.setTypeParser(oid, str => array.parse(str)));
40
34
  ret.types = types;
41
- return knex_1.Utils.mergeConfig(ret, overrides);
35
+ return Utils.mergeConfig(ret, overrides);
42
36
  }
43
37
  }
44
- exports.PostgreSqlConnection = PostgreSqlConnection;
@@ -1,6 +1,9 @@
1
- import type { Configuration } from '@mikro-orm/core';
2
- import { AbstractSqlDriver } from '@mikro-orm/knex';
3
- import { PostgreSqlConnection } from './PostgreSqlConnection';
1
+ import type { Configuration, Constructor } from '@mikro-orm/core';
2
+ import { AbstractSqlDriver } from '@mikro-orm/sql';
3
+ import { PostgreSqlConnection } from './PostgreSqlConnection.js';
4
+ import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
4
5
  export declare class PostgreSqlDriver extends AbstractSqlDriver<PostgreSqlConnection> {
5
6
  constructor(config: Configuration);
7
+ /** @inheritDoc */
8
+ getORMClass(): Constructor<PostgreSqlMikroORM>;
6
9
  }
@@ -1,12 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgreSqlDriver = void 0;
4
- const knex_1 = require("@mikro-orm/knex");
5
- const PostgreSqlConnection_1 = require("./PostgreSqlConnection");
6
- const PostgreSqlPlatform_1 = require("./PostgreSqlPlatform");
7
- class PostgreSqlDriver extends knex_1.AbstractSqlDriver {
1
+ import { AbstractSqlDriver } from '@mikro-orm/sql';
2
+ import { PostgreSqlConnection } from './PostgreSqlConnection.js';
3
+ import { PostgreSqlPlatform } from './PostgreSqlPlatform.js';
4
+ import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
5
+ export class PostgreSqlDriver extends AbstractSqlDriver {
8
6
  constructor(config) {
9
- super(config, new PostgreSqlPlatform_1.PostgreSqlPlatform(), PostgreSqlConnection_1.PostgreSqlConnection, ['kysely', 'pg']);
7
+ super(config, new PostgreSqlPlatform(), PostgreSqlConnection, ['kysely', 'pg']);
8
+ }
9
+ /** @inheritDoc */
10
+ getORMClass() {
11
+ return PostgreSqlMikroORM;
10
12
  }
11
13
  }
12
- exports.PostgreSqlDriver = PostgreSqlDriver;
@@ -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
3
  /**
4
- * @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
5
- * @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
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
6
  */
7
7
  convertException(exception: Error & Dictionary): DriverException;
8
8
  }
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgreSqlExceptionConverter = void 0;
4
- const core_1 = require("@mikro-orm/core");
5
- class PostgreSqlExceptionConverter extends core_1.ExceptionConverter {
6
- /* istanbul ignore next */
1
+ import { DeadlockException, ExceptionConverter, ForeignKeyConstraintViolationException, InvalidFieldNameException, NonUniqueFieldNameException, NotNullConstraintViolationException, SyntaxErrorException, TableExistsException, TableNotFoundException, UniqueConstraintViolationException, CheckConstraintViolationException, } from '@mikro-orm/core';
2
+ export class PostgreSqlExceptionConverter extends ExceptionConverter {
7
3
  /**
8
- * @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
9
- * @link https://github.com/doctrine/dbal/blob/master/src/Driver/AbstractPostgreSQLDriver.php
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
10
6
  */
11
7
  convertException(exception) {
12
8
  if (exception.detail?.toString().trim()) {
@@ -15,37 +11,37 @@ class PostgreSqlExceptionConverter extends core_1.ExceptionConverter {
15
11
  if (exception.hint?.toString().trim()) {
16
12
  exception.message += '\n - hint: ' + exception.hint;
17
13
  }
14
+ /* v8 ignore next */
18
15
  switch (exception.code) {
19
16
  case '40001':
20
17
  case '40P01':
21
- return new core_1.DeadlockException(exception);
18
+ return new DeadlockException(exception);
22
19
  case '0A000':
23
20
  // Foreign key constraint violations during a TRUNCATE operation
24
21
  // are considered "feature not supported" in PostgreSQL.
25
22
  if (exception.message.includes('truncate')) {
26
- return new core_1.ForeignKeyConstraintViolationException(exception);
23
+ return new ForeignKeyConstraintViolationException(exception);
27
24
  }
28
25
  break;
29
26
  case '23502':
30
- return new core_1.NotNullConstraintViolationException(exception);
27
+ return new NotNullConstraintViolationException(exception);
31
28
  case '23503':
32
- return new core_1.ForeignKeyConstraintViolationException(exception);
29
+ return new ForeignKeyConstraintViolationException(exception);
33
30
  case '23505':
34
- return new core_1.UniqueConstraintViolationException(exception);
31
+ return new UniqueConstraintViolationException(exception);
35
32
  case '23514':
36
- return new core_1.CheckConstraintViolationException(exception);
33
+ return new CheckConstraintViolationException(exception);
37
34
  case '42601':
38
- return new core_1.SyntaxErrorException(exception);
35
+ return new SyntaxErrorException(exception);
39
36
  case '42702':
40
- return new core_1.NonUniqueFieldNameException(exception);
37
+ return new NonUniqueFieldNameException(exception);
41
38
  case '42703':
42
- return new core_1.InvalidFieldNameException(exception);
39
+ return new InvalidFieldNameException(exception);
43
40
  case '42P01':
44
- return new core_1.TableNotFoundException(exception);
41
+ return new TableNotFoundException(exception);
45
42
  case '42P07':
46
- return new core_1.TableExistsException(exception);
43
+ return new TableExistsException(exception);
47
44
  }
48
45
  return super.convertException(exception);
49
46
  }
50
47
  }
51
- exports.PostgreSqlExceptionConverter = PostgreSqlExceptionConverter;
@@ -1,19 +1,18 @@
1
- import { MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
2
- import { PostgreSqlDriver } from './PostgreSqlDriver';
3
- import type { SqlEntityManager } from '@mikro-orm/knex';
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
+ 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>;
4
6
  /**
5
7
  * @inheritDoc
6
8
  */
7
- export declare class PostgreSqlMikroORM<EM extends EntityManager = SqlEntityManager> extends MikroORM<PostgreSqlDriver, EM> {
8
- private static DRIVER;
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
10
  /**
10
11
  * @inheritDoc
11
12
  */
12
- static init<D extends IDatabaseDriver = PostgreSqlDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager>(options?: Options<D, EM>): Promise<MikroORM<D, EM>>;
13
+ static init<D extends IDatabaseDriver = PostgreSqlDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Promise<MikroORM<D, EM, Entities>>;
13
14
  /**
14
15
  * @inheritDoc
15
16
  */
16
- static initSync<D extends IDatabaseDriver = PostgreSqlDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager>(options: Options<D, EM>): MikroORM<D, EM>;
17
+ constructor(options: Options<PostgreSqlDriver, EM, Entities>);
17
18
  }
18
- export type PostgreSqlOptions = Options<PostgreSqlDriver>;
19
- export declare function definePostgreSqlConfig(options: PostgreSqlOptions): Options<PostgreSqlDriver, SqlEntityManager<PostgreSqlDriver> & EntityManager<IDatabaseDriver<import("@mikro-orm/core").Connection>>>;
@@ -1,29 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgreSqlMikroORM = void 0;
4
- exports.definePostgreSqlConfig = definePostgreSqlConfig;
5
- const core_1 = require("@mikro-orm/core");
6
- const PostgreSqlDriver_1 = require("./PostgreSqlDriver");
1
+ import { defineConfig, MikroORM, } from '@mikro-orm/core';
2
+ import { PostgreSqlDriver } from './PostgreSqlDriver.js';
3
+ export function definePostgreSqlConfig(options) {
4
+ return defineConfig({ driver: PostgreSqlDriver, ...options });
5
+ }
7
6
  /**
8
7
  * @inheritDoc
9
8
  */
10
- class PostgreSqlMikroORM extends core_1.MikroORM {
11
- static DRIVER = PostgreSqlDriver_1.PostgreSqlDriver;
9
+ export class PostgreSqlMikroORM extends MikroORM {
12
10
  /**
13
11
  * @inheritDoc
14
12
  */
15
13
  static async init(options) {
16
- return super.init(options);
14
+ return super.init(definePostgreSqlConfig(options));
17
15
  }
18
16
  /**
19
17
  * @inheritDoc
20
18
  */
21
- static initSync(options) {
22
- return super.initSync(options);
19
+ constructor(options) {
20
+ super(definePostgreSqlConfig(options));
23
21
  }
24
22
  }
25
- exports.PostgreSqlMikroORM = PostgreSqlMikroORM;
26
- /* istanbul ignore next */
27
- function definePostgreSqlConfig(options) {
28
- return (0, core_1.defineConfig)({ driver: PostgreSqlDriver_1.PostgreSqlDriver, ...options });
29
- }
@@ -1,8 +1,8 @@
1
1
  import { type IPostgresInterval } from 'postgres-interval';
2
- import { type IsolationLevel, type EntityProperty, Type, type SimpleColumnMeta, type Configuration } from '@mikro-orm/core';
3
- import { AbstractSqlPlatform, type IndexDef, PostgreSqlNativeQueryBuilder } from '@mikro-orm/knex';
4
- import { PostgreSqlSchemaHelper } from './PostgreSqlSchemaHelper';
5
- import { PostgreSqlExceptionConverter } from './PostgreSqlExceptionConverter';
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
6
  export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
7
7
  protected readonly schemaHelper: PostgreSqlSchemaHelper;
8
8
  protected readonly exceptionConverter: PostgreSqlExceptionConverter;
@@ -81,7 +81,9 @@ export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
81
81
  getJsonDeclarationSQL(): string;
82
82
  getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string;
83
83
  getJsonIndexDefinition(index: IndexDef): string[];
84
- quoteIdentifier(id: string, quote?: string): string;
84
+ quoteIdentifier(id: string | {
85
+ toString: () => string;
86
+ }, quote?: string): string;
85
87
  escape(value: any): string;
86
88
  private pad;
87
89
  /** @internal */
@@ -1,20 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PostgreSqlPlatform = void 0;
7
- const pg_1 = require("pg");
8
- const postgres_date_1 = __importDefault(require("postgres-date"));
9
- const postgres_interval_1 = __importDefault(require("postgres-interval"));
10
- const core_1 = require("@mikro-orm/core");
11
- const knex_1 = require("@mikro-orm/knex");
12
- const PostgreSqlSchemaHelper_1 = require("./PostgreSqlSchemaHelper");
13
- const PostgreSqlExceptionConverter_1 = require("./PostgreSqlExceptionConverter");
14
- const FullTextType_1 = require("./types/FullTextType");
15
- class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
16
- schemaHelper = new PostgreSqlSchemaHelper_1.PostgreSqlSchemaHelper(this);
17
- exceptionConverter = new PostgreSqlExceptionConverter_1.PostgreSqlExceptionConverter();
1
+ import { Client } from 'pg';
2
+ import parseDate from 'postgres-date';
3
+ 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();
18
12
  setConfig(config) {
19
13
  if (config.get('forceUtcTimezone') == null) {
20
14
  config.set('forceUtcTimezone', true);
@@ -22,7 +16,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
22
16
  super.setConfig(config);
23
17
  }
24
18
  createNativeQueryBuilder() {
25
- return new knex_1.PostgreSqlNativeQueryBuilder(this);
19
+ return new PostgreSqlNativeQueryBuilder(this);
26
20
  }
27
21
  usesReturningStatement() {
28
22
  return true;
@@ -43,17 +37,17 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
43
37
  return `current_timestamp(${length})`;
44
38
  }
45
39
  getDateTimeTypeDeclarationSQL(column) {
46
- /* istanbul ignore next */
40
+ /* v8 ignore next */
47
41
  return 'timestamptz' + (column.length != null ? `(${column.length})` : '');
48
42
  }
49
43
  getDefaultDateTimeLength() {
50
44
  return 6;
51
45
  }
52
46
  convertIntervalToJSValue(value) {
53
- return (0, postgres_interval_1.default)(value);
47
+ return PostgresInterval(value);
54
48
  }
55
49
  convertIntervalToDatabaseValue(value) {
56
- if (core_1.Utils.isObject(value) && 'toPostgres' in value && typeof value.toPostgres === 'function') {
50
+ if (Utils.isObject(value) && 'toPostgres' in value && typeof value.toPostgres === 'function') {
57
51
  return value.toPostgres();
58
52
  }
59
53
  return value;
@@ -68,7 +62,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
68
62
  return 'int';
69
63
  }
70
64
  getBigIntTypeDeclarationSQL(column) {
71
- /* istanbul ignore next */
65
+ /* v8 ignore next */
72
66
  if (column.autoincrement) {
73
67
  return `bigserial`;
74
68
  }
@@ -81,10 +75,10 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
81
75
  return `uuid`;
82
76
  }
83
77
  getFullTextWhereClause(prop) {
84
- if (prop.customType instanceof FullTextType_1.FullTextType) {
78
+ if (prop.customType instanceof FullTextType) {
85
79
  return `:column: @@ plainto_tsquery('${prop.customType.regconfig}', :query)`;
86
80
  }
87
- /* istanbul ignore next */
81
+ /* v8 ignore next */
88
82
  if (prop.columnTypes[0] === 'tsvector') {
89
83
  return `:column: @@ plainto_tsquery('simple', :query)`;
90
84
  }
@@ -94,7 +88,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
94
88
  return true;
95
89
  }
96
90
  getFullTextIndexExpression(indexName, schemaName, tableName, columns) {
97
- /* istanbul ignore next */
91
+ /* v8 ignore next */
98
92
  const quotedTableName = this.quoteIdentifier(schemaName ? `${schemaName}.${tableName}` : tableName);
99
93
  const quotedColumnNames = columns.map(c => this.quoteIdentifier(c.name));
100
94
  const quotedIndexName = this.quoteIdentifier(indexName);
@@ -133,23 +127,22 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
133
127
  }
134
128
  getMappedType(type) {
135
129
  switch (this.extractSimpleType(type)) {
136
- case 'tsvector': return core_1.Type.getType(FullTextType_1.FullTextType);
130
+ case 'tsvector': return Type.getType(FullTextType);
137
131
  default: return super.getMappedType(type);
138
132
  }
139
133
  }
140
134
  getRegExpOperator(val, flags) {
141
- /* istanbul ignore next */
135
+ /* v8 ignore next */
142
136
  if ((val instanceof RegExp && val.flags.includes('i')) || flags?.includes('i')) {
143
137
  return '~*';
144
138
  }
145
139
  return '~';
146
140
  }
141
+ /* v8 ignore next */
147
142
  getRegExpValue(val) {
148
- /* istanbul ignore else */
149
143
  if (val.flags.includes('i')) {
150
144
  return { $re: val.source, $flags: val.flags };
151
145
  }
152
- /* istanbul ignore next */
153
146
  return { $re: val.source };
154
147
  }
155
148
  isBigIntProperty(prop) {
@@ -165,11 +158,11 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
165
158
  return 'double precision';
166
159
  }
167
160
  getEnumTypeDeclarationSQL(column) {
168
- /* istanbul ignore next */
161
+ /* v8 ignore next */
169
162
  if (column.nativeEnumName) {
170
163
  return column.nativeEnumName;
171
164
  }
172
- if (column.items?.every(item => core_1.Utils.isString(item))) {
165
+ if (column.items?.every(item => typeof item === 'string')) {
173
166
  return 'text';
174
167
  }
175
168
  return `smallint`;
@@ -228,17 +221,17 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
228
221
  getSearchJsonPropertyKey(path, type, aliased, value) {
229
222
  const first = path.shift();
230
223
  const last = path.pop();
231
- const root = this.quoteIdentifier(aliased ? `${core_1.ALIAS_REPLACEMENT}.${first}` : first);
224
+ const root = this.quoteIdentifier(aliased ? `${ALIAS_REPLACEMENT}.${first}` : first);
232
225
  type = typeof type === 'string' ? this.getMappedType(type).runtimeType : String(type);
233
226
  const types = {
234
227
  number: 'float8',
235
228
  bigint: 'int8',
236
229
  boolean: 'bool',
237
230
  };
238
- const cast = (key) => (0, core_1.raw)(type in types ? `(${key})::${types[type]}` : key);
231
+ const cast = (key) => raw(type in types ? `(${key})::${types[type]}` : key);
239
232
  let lastOperator = '->>';
240
233
  // force `->` for operator payloads with array values
241
- if (core_1.Utils.isPlainObject(value) && Object.keys(value).every(key => core_1.Utils.isArrayOperator(key) && Array.isArray(value[key]))) {
234
+ if (Utils.isPlainObject(value) && Object.keys(value).every(key => ARRAY_OPERATORS.includes(key) && Array.isArray(value[key]))) {
242
235
  lastOperator = '->';
243
236
  }
244
237
  if (path.length === 0) {
@@ -262,14 +255,17 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
262
255
  });
263
256
  }
264
257
  quoteIdentifier(id, quote = '"') {
265
- if (core_1.RawQueryFragment.isKnownFragment(id)) {
258
+ if (RawQueryFragment.isKnownFragment(id)) {
266
259
  return super.quoteIdentifier(id);
267
260
  }
268
- return `${quote}${id.replace('.', `${quote}.${quote}`)}${quote}`;
261
+ return `${quote}${id.toString().replace('.', `${quote}.${quote}`)}${quote}`;
269
262
  }
270
263
  escape(value) {
264
+ if (typeof value === 'bigint') {
265
+ value = value.toString();
266
+ }
271
267
  if (typeof value === 'string') {
272
- return pg_1.Client.prototype.escapeLiteral(value);
268
+ return Client.prototype.escapeLiteral(value);
273
269
  }
274
270
  if (value instanceof Date) {
275
271
  return `'${this.formatDate(value)}'`;
@@ -277,7 +273,10 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
277
273
  if (ArrayBuffer.isView(value)) {
278
274
  return `E'\\\\x${value.toString('hex')}'`;
279
275
  }
280
- return super.escape(value);
276
+ if (Array.isArray(value)) {
277
+ return value.map(v => this.escape(v)).join(', ');
278
+ }
279
+ return value;
281
280
  }
282
281
  pad(number, digits) {
283
282
  return String(number).padStart(digits, '0');
@@ -290,14 +289,14 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
290
289
  let offset = -date.getTimezoneOffset();
291
290
  let year = date.getFullYear();
292
291
  const isBCYear = year < 1;
293
- /* istanbul ignore next */
292
+ /* v8 ignore next */
294
293
  if (isBCYear) {
295
294
  year = Math.abs(year) + 1;
296
295
  }
297
296
  const datePart = `${this.pad(year, 4)}-${this.pad(date.getMonth() + 1, 2)}-${this.pad(date.getDate(), 2)}`;
298
297
  const timePart = `${this.pad(date.getHours(), 2)}:${this.pad(date.getMinutes(), 2)}:${this.pad(date.getSeconds(), 2)}.${this.pad(date.getMilliseconds(), 3)}`;
299
298
  let ret = `${datePart}T${timePart}`;
300
- /* istanbul ignore if */
299
+ /* v8 ignore next */
301
300
  if (offset < 0) {
302
301
  ret += '-';
303
302
  offset *= -1;
@@ -306,7 +305,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
306
305
  ret += '+';
307
306
  }
308
307
  ret += this.pad(Math.floor(offset / 60), 2) + ':' + this.pad(offset % 60, 2);
309
- /* istanbul ignore next */
308
+ /* v8 ignore next */
310
309
  if (isBCYear) {
311
310
  ret += ' BC';
312
311
  }
@@ -355,14 +354,14 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
355
354
  const indexName = super.getIndexName(tableName, columns, type);
356
355
  if (indexName.length > 63) {
357
356
  const suffix = type === 'primary' ? 'pkey' : type;
358
- return `${indexName.substring(0, 55 - type.length)}_${core_1.Utils.hash(indexName, 5)}_${suffix}`;
357
+ return `${indexName.substring(0, 55 - type.length)}_${Utils.hash(indexName, 5)}_${suffix}`;
359
358
  }
360
359
  return indexName;
361
360
  }
362
361
  getDefaultPrimaryName(tableName, columns) {
363
362
  const indexName = `${tableName}_pkey`;
364
363
  if (indexName.length > 63) {
365
- return `${indexName.substring(0, 55 - 'pkey'.length)}_${core_1.Utils.hash(indexName, 5)}_pkey`;
364
+ return `${indexName.substring(0, 55 - 'pkey'.length)}_${Utils.hash(indexName, 5)}_pkey`;
366
365
  }
367
366
  return indexName;
368
367
  }
@@ -384,12 +383,13 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
384
383
  if (typeof value === 'string' && value.charAt(10) === 'T') {
385
384
  return new Date(value);
386
385
  }
387
- /* istanbul ignore next */
386
+ /* v8 ignore next */
388
387
  if (typeof value === 'number') {
389
388
  return new Date(value);
390
389
  }
391
- const parsed = (0, postgres_date_1.default)(value);
392
- /* istanbul ignore next */
390
+ // @ts-ignore fix wrong type resolution during build
391
+ const parsed = parseDate(value);
392
+ /* v8 ignore next */
393
393
  if (parsed === null) {
394
394
  return value;
395
395
  }
@@ -399,4 +399,3 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
399
399
  return 'postgresql://postgres@127.0.0.1:5432';
400
400
  }
401
401
  }
402
- exports.PostgreSqlPlatform = PostgreSqlPlatform;
@@ -1,5 +1,5 @@
1
1
  import { type Dictionary } from '@mikro-orm/core';
2
- import { SchemaHelper, type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type ForeignKey, type IndexDef, type Table, type TableDifference } from '@mikro-orm/knex';
2
+ import { SchemaHelper, type AbstractSqlConnection, type CheckDef, type Column, type DatabaseSchema, type DatabaseTable, type ForeignKey, type IndexDef, type Table, type TableDifference } from '@mikro-orm/sql';
3
3
  export declare class PostgreSqlSchemaHelper extends SchemaHelper {
4
4
  static readonly DEFAULT_VALUES: {
5
5
  'now()': string[];