@mikro-orm/postgresql 7.0.4-dev.9 → 7.0.4

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.
@@ -3,6 +3,6 @@ import { PostgresDialect } from 'kysely';
3
3
  import { AbstractSqlConnection } from '@mikro-orm/sql';
4
4
  /** PostgreSQL database connection using the `pg` driver. */
5
5
  export declare class PostgreSqlConnection extends AbstractSqlConnection {
6
- createKyselyDialect(overrides: PoolConfig): PostgresDialect;
7
- mapOptions(overrides: PoolConfig): PoolConfig;
6
+ createKyselyDialect(overrides: PoolConfig): PostgresDialect;
7
+ mapOptions(overrides: PoolConfig): PoolConfig;
8
8
  }
@@ -5,34 +5,34 @@ import array from 'postgres-array';
5
5
  import { AbstractSqlConnection, Utils } from '@mikro-orm/sql';
6
6
  /** PostgreSQL database connection using the `pg` driver. */
7
7
  export class PostgreSqlConnection extends AbstractSqlConnection {
8
- createKyselyDialect(overrides) {
9
- const options = this.mapOptions(overrides);
10
- return new PostgresDialect({
11
- pool: new Pool(options),
12
- cursor: Cursor,
13
- onCreateConnection: this.options.onCreateConnection ?? this.config.get('onCreateConnection'),
14
- });
15
- }
16
- mapOptions(overrides) {
17
- const ret = { ...this.getConnectionOptions() };
18
- const pool = this.config.get('pool');
19
- Utils.defaultValue(ret, 'max', pool?.max);
20
- Utils.defaultValue(ret, 'idleTimeoutMillis', pool?.idleTimeoutMillis);
21
- // use `select typname, oid, typarray from pg_type order by oid` to get the list of OIDs
22
- const types = new TypeOverrides();
23
- [
24
- 1082, // date
25
- 1114, // timestamp
26
- 1184, // timestamptz
27
- 1186, // interval
28
- ].forEach(oid => types.setTypeParser(oid, str => str));
29
- [
30
- 1182, // date[]
31
- 1115, // timestamp[]
32
- 1185, // timestamptz[]
33
- 1187, // interval[]
34
- ].forEach(oid => types.setTypeParser(oid, str => array.parse(str)));
35
- ret.types = types;
36
- return Utils.mergeConfig(ret, overrides);
37
- }
8
+ createKyselyDialect(overrides) {
9
+ const options = this.mapOptions(overrides);
10
+ return new PostgresDialect({
11
+ pool: new Pool(options),
12
+ cursor: Cursor,
13
+ onCreateConnection: this.options.onCreateConnection ?? this.config.get('onCreateConnection'),
14
+ });
15
+ }
16
+ mapOptions(overrides) {
17
+ const ret = { ...this.getConnectionOptions() };
18
+ const pool = this.config.get('pool');
19
+ Utils.defaultValue(ret, 'max', pool?.max);
20
+ Utils.defaultValue(ret, 'idleTimeoutMillis', pool?.idleTimeoutMillis);
21
+ // use `select typname, oid, typarray from pg_type order by oid` to get the list of OIDs
22
+ const types = new TypeOverrides();
23
+ [
24
+ 1082, // date
25
+ 1114, // timestamp
26
+ 1184, // timestamptz
27
+ 1186, // interval
28
+ ].forEach(oid => types.setTypeParser(oid, str => str));
29
+ [
30
+ 1182, // date[]
31
+ 1115, // timestamp[]
32
+ 1185, // timestamptz[]
33
+ 1187, // interval[]
34
+ ].forEach(oid => types.setTypeParser(oid, str => array.parse(str)));
35
+ ret.types = types;
36
+ return Utils.mergeConfig(ret, overrides);
37
+ }
38
38
  }
@@ -5,9 +5,9 @@ import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
5
5
  import { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
6
6
  /** Database driver for PostgreSQL. */
7
7
  export declare class PostgreSqlDriver extends AbstractSqlDriver<PostgreSqlConnection> {
8
- [EntityManagerType]: PostgreSqlEntityManager<this>;
9
- constructor(config: Configuration);
10
- createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
11
- /** @inheritDoc */
12
- getORMClass(): Constructor<PostgreSqlMikroORM>;
8
+ [EntityManagerType]: PostgreSqlEntityManager<this>;
9
+ constructor(config: Configuration);
10
+ createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
11
+ /** @inheritDoc */
12
+ getORMClass(): Constructor<PostgreSqlMikroORM>;
13
13
  }
@@ -6,16 +6,16 @@ import { PostgreSqlMikroORM } from './PostgreSqlMikroORM.js';
6
6
  import { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
7
7
  /** Database driver for PostgreSQL. */
8
8
  export class PostgreSqlDriver extends AbstractSqlDriver {
9
- [EntityManagerType];
10
- constructor(config) {
11
- super(config, new PostgreSqlPlatform(), PostgreSqlConnection, ['kysely', 'pg']);
12
- }
13
- createEntityManager(useContext) {
14
- const EntityManagerClass = this.config.get('entityManager', PostgreSqlEntityManager);
15
- return new EntityManagerClass(this.config, this, this.metadata, useContext);
16
- }
17
- /** @inheritDoc */
18
- getORMClass() {
19
- return PostgreSqlMikroORM;
20
- }
9
+ [EntityManagerType];
10
+ constructor(config) {
11
+ super(config, new PostgreSqlPlatform(), PostgreSqlConnection, ['kysely', 'pg']);
12
+ }
13
+ createEntityManager(useContext) {
14
+ const EntityManagerClass = this.config.get('entityManager', PostgreSqlEntityManager);
15
+ return new EntityManagerClass(this.config, this, this.metadata, useContext);
16
+ }
17
+ /** @inheritDoc */
18
+ getORMClass() {
19
+ return PostgreSqlMikroORM;
20
+ }
21
21
  }
@@ -4,15 +4,20 @@ import type { PostgreSqlDriver } from './PostgreSqlDriver.js';
4
4
  /**
5
5
  * @inheritDoc
6
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>;
7
+ export declare class PostgreSqlEntityManager<
8
+ Driver extends PostgreSqlDriver = PostgreSqlDriver,
9
+ > extends SqlEntityManager<Driver> {
10
+ /**
11
+ * Refreshes a materialized view.
12
+ *
13
+ * @param entityName - The entity name or class of the materialized view
14
+ * @param options - Optional settings
15
+ * @param options.concurrently - If true, refreshes the view concurrently (requires a unique index on the view)
16
+ */
17
+ refreshMaterializedView<Entity extends object>(
18
+ entityName: EntityName<Entity>,
19
+ options?: {
20
+ concurrently?: boolean;
21
+ },
22
+ ): Promise<void>;
18
23
  }
@@ -3,21 +3,21 @@ import { SqlEntityManager } from '@mikro-orm/sql';
3
3
  * @inheritDoc
4
4
  */
5
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);
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`);
22
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
23
  }
@@ -1,20 +1,58 @@
1
- import { type AnyEntity, type EntityClass, type EntitySchema, MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
1
+ import {
2
+ type AnyEntity,
3
+ type EntityClass,
4
+ type EntitySchema,
5
+ MikroORM,
6
+ type Options,
7
+ type IDatabaseDriver,
8
+ type EntityManager,
9
+ type EntityManagerType,
10
+ } from '@mikro-orm/core';
2
11
  import { PostgreSqlDriver } from './PostgreSqlDriver.js';
3
12
  import type { PostgreSqlEntityManager } from './PostgreSqlEntityManager.js';
4
13
  /** Configuration options for the PostgreSQL driver. */
5
- export type PostgreSqlOptions<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Partial<Options<PostgreSqlDriver, EM, Entities>>;
14
+ export type PostgreSqlOptions<
15
+ EM extends PostgreSqlEntityManager = PostgreSqlEntityManager,
16
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
17
+ | string
18
+ | EntityClass<AnyEntity>
19
+ | EntitySchema
20
+ )[],
21
+ > = Partial<Options<PostgreSqlDriver, EM, Entities>>;
6
22
  /** Creates a type-safe configuration object for the PostgreSQL driver. */
7
- export declare function definePostgreSqlConfig<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<PostgreSqlDriver, EM, Entities>>): Partial<Options<PostgreSqlDriver, EM, Entities>>;
23
+ export declare function definePostgreSqlConfig<
24
+ EM extends PostgreSqlEntityManager = PostgreSqlEntityManager,
25
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
26
+ | string
27
+ | EntityClass<AnyEntity>
28
+ | EntitySchema
29
+ )[],
30
+ >(options: Partial<Options<PostgreSqlDriver, EM, Entities>>): Partial<Options<PostgreSqlDriver, EM, Entities>>;
8
31
  /**
9
32
  * @inheritDoc
10
33
  */
11
- export declare class PostgreSqlMikroORM<EM extends PostgreSqlEntityManager = PostgreSqlEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<PostgreSqlDriver, EM, Entities> {
12
- /**
13
- * @inheritDoc
14
- */
15
- 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: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
16
- /**
17
- * @inheritDoc
18
- */
19
- constructor(options: Partial<Options<PostgreSqlDriver, EM, Entities>>);
34
+ export declare class PostgreSqlMikroORM<
35
+ EM extends PostgreSqlEntityManager = PostgreSqlEntityManager,
36
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
37
+ | string
38
+ | EntityClass<AnyEntity>
39
+ | EntitySchema
40
+ )[],
41
+ > extends MikroORM<PostgreSqlDriver, EM, Entities> {
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ static init<
46
+ D extends IDatabaseDriver = PostgreSqlDriver,
47
+ EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>,
48
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
49
+ | string
50
+ | EntityClass<AnyEntity>
51
+ | EntitySchema
52
+ )[],
53
+ >(options: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ constructor(options: Partial<Options<PostgreSqlDriver, EM, Entities>>);
20
58
  }
@@ -1,23 +1,23 @@
1
- import { defineConfig, MikroORM, } from '@mikro-orm/core';
1
+ import { defineConfig, MikroORM } from '@mikro-orm/core';
2
2
  import { PostgreSqlDriver } from './PostgreSqlDriver.js';
3
3
  /** Creates a type-safe configuration object for the PostgreSQL driver. */
4
4
  export function definePostgreSqlConfig(options) {
5
- return defineConfig({ driver: PostgreSqlDriver, ...options });
5
+ return defineConfig({ driver: PostgreSqlDriver, ...options });
6
6
  }
7
7
  /**
8
8
  * @inheritDoc
9
9
  */
10
10
  export class PostgreSqlMikroORM extends MikroORM {
11
- /**
12
- * @inheritDoc
13
- */
14
- static async init(options) {
15
- return super.init(definePostgreSqlConfig(options));
16
- }
17
- /**
18
- * @inheritDoc
19
- */
20
- constructor(options) {
21
- super(definePostgreSqlConfig(options));
22
- }
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ static async init(options) {
15
+ return super.init(definePostgreSqlConfig(options));
16
+ }
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ constructor(options) {
21
+ super(definePostgreSqlConfig(options));
22
+ }
23
23
  }
@@ -2,12 +2,12 @@ import { type IPostgresInterval } from 'postgres-interval';
2
2
  import { BasePostgreSqlPlatform } from '@mikro-orm/sql';
3
3
  /** Platform implementation for PostgreSQL. */
4
4
  export declare class PostgreSqlPlatform extends BasePostgreSqlPlatform {
5
- convertIntervalToJSValue(value: string): unknown;
6
- convertIntervalToDatabaseValue(value: IPostgresInterval): unknown;
7
- unmarshallArray(value: string): string[];
8
- escape(value: any): string;
9
- /**
10
- * @inheritDoc
11
- */
12
- parseDate(value: string | number): Date;
5
+ convertIntervalToJSValue(value: string): unknown;
6
+ convertIntervalToDatabaseValue(value: IPostgresInterval): unknown;
7
+ unmarshallArray(value: string): string[];
8
+ escape(value: any): string;
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ parseDate(value: string | number): Date;
13
13
  }
@@ -5,54 +5,54 @@ import PostgresInterval from 'postgres-interval';
5
5
  import { BasePostgreSqlPlatform, Utils } from '@mikro-orm/sql';
6
6
  /** Platform implementation for PostgreSQL. */
7
7
  export class PostgreSqlPlatform extends BasePostgreSqlPlatform {
8
- convertIntervalToJSValue(value) {
9
- return PostgresInterval(value);
10
- }
11
- convertIntervalToDatabaseValue(value) {
12
- if (Utils.isObject(value) && 'toPostgres' in value && typeof value.toPostgres === 'function') {
13
- return value.toPostgres();
14
- }
15
- return value;
16
- }
17
- unmarshallArray(value) {
18
- return array.parse(value);
19
- }
20
- escape(value) {
21
- if (typeof value === 'bigint') {
22
- value = value.toString();
23
- }
24
- if (typeof value === 'string') {
25
- return Client.prototype.escapeLiteral(value);
26
- }
27
- if (value instanceof Date) {
28
- return `'${this.formatDate(value)}'`;
29
- }
30
- if (ArrayBuffer.isView(value)) {
31
- return `E'\\\\x${value.toString('hex')}'`;
32
- }
33
- if (Array.isArray(value)) {
34
- return value.map(v => this.escape(v)).join(', ');
35
- }
36
- return value;
37
- }
38
- /**
39
- * @inheritDoc
40
- */
41
- parseDate(value) {
42
- // postgres-date returns `null` for a JS ISO string which has the `T` separator
43
- if (typeof value === 'string' && value.charAt(10) === 'T') {
44
- return new Date(value);
45
- }
46
- /* v8 ignore next */
47
- if (typeof value === 'number') {
48
- return new Date(value);
49
- }
50
- // @ts-ignore fix wrong type resolution during build
51
- const parsed = parseDate(value);
52
- /* v8 ignore next */
53
- if (parsed === null) {
54
- return value;
55
- }
56
- return parsed;
8
+ convertIntervalToJSValue(value) {
9
+ return PostgresInterval(value);
10
+ }
11
+ convertIntervalToDatabaseValue(value) {
12
+ if (Utils.isObject(value) && 'toPostgres' in value && typeof value.toPostgres === 'function') {
13
+ return value.toPostgres();
57
14
  }
15
+ return value;
16
+ }
17
+ unmarshallArray(value) {
18
+ return array.parse(value);
19
+ }
20
+ escape(value) {
21
+ if (typeof value === 'bigint') {
22
+ value = value.toString();
23
+ }
24
+ if (typeof value === 'string') {
25
+ return Client.prototype.escapeLiteral(value);
26
+ }
27
+ if (value instanceof Date) {
28
+ return `'${this.formatDate(value)}'`;
29
+ }
30
+ if (ArrayBuffer.isView(value)) {
31
+ return `E'\\\\x${value.toString('hex')}'`;
32
+ }
33
+ if (Array.isArray(value)) {
34
+ return value.map(v => this.escape(v)).join(', ');
35
+ }
36
+ return value;
37
+ }
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ parseDate(value) {
42
+ // postgres-date returns `null` for a JS ISO string which has the `T` separator
43
+ if (typeof value === 'string' && value.charAt(10) === 'T') {
44
+ return new Date(value);
45
+ }
46
+ /* v8 ignore next */
47
+ if (typeof value === 'number') {
48
+ return new Date(value);
49
+ }
50
+ // @ts-ignore fix wrong type resolution during build
51
+ const parsed = parseDate(value);
52
+ /* v8 ignore next */
53
+ if (parsed === null) {
54
+ return value;
55
+ }
56
+ return parsed;
57
+ }
58
58
  }
package/README.md CHANGED
@@ -133,7 +133,7 @@ const author = await em.findOneOrFail(Author, 1, {
133
133
  populate: ['books'],
134
134
  });
135
135
  author.name = 'Jon Snow II';
136
- author.books.getItems().forEach(book => book.title += ' (2nd ed.)');
136
+ author.books.getItems().forEach(book => (book.title += ' (2nd ed.)'));
137
137
  author.books.add(orm.em.create(Book, { title: 'New Book', author }));
138
138
 
139
139
  // Flush computes change sets and executes them in a single transaction
package/index.d.ts CHANGED
@@ -3,5 +3,9 @@ export * from './PostgreSqlConnection.js';
3
3
  export * from './PostgreSqlDriver.js';
4
4
  export * from './PostgreSqlPlatform.js';
5
5
  export { PostgreSqlEntityManager as EntityManager } from './PostgreSqlEntityManager.js';
6
- export { PostgreSqlMikroORM as MikroORM, type PostgreSqlOptions as Options, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
6
+ export {
7
+ PostgreSqlMikroORM as MikroORM,
8
+ type PostgreSqlOptions as Options,
9
+ definePostgreSqlConfig as defineConfig,
10
+ } from './PostgreSqlMikroORM.js';
7
11
  export { raw } from './raw.js';
package/index.js CHANGED
@@ -3,5 +3,5 @@ export * from './PostgreSqlConnection.js';
3
3
  export * from './PostgreSqlDriver.js';
4
4
  export * from './PostgreSqlPlatform.js';
5
5
  export { PostgreSqlEntityManager as EntityManager } from './PostgreSqlEntityManager.js';
6
- export { PostgreSqlMikroORM as MikroORM, definePostgreSqlConfig as defineConfig, } from './PostgreSqlMikroORM.js';
6
+ export { PostgreSqlMikroORM as MikroORM, definePostgreSqlConfig as defineConfig } from './PostgreSqlMikroORM.js';
7
7
  export { raw } from './raw.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/postgresql",
3
- "version": "7.0.4-dev.9",
3
+ "version": "7.0.4",
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",
@@ -47,7 +47,7 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "@mikro-orm/sql": "7.0.4-dev.9",
50
+ "@mikro-orm/sql": "7.0.4",
51
51
  "kysely": "0.28.13",
52
52
  "pg": "8.20.0",
53
53
  "pg-cursor": "2.19.0",
@@ -56,10 +56,10 @@
56
56
  "postgres-interval": "4.0.2"
57
57
  },
58
58
  "devDependencies": {
59
- "@mikro-orm/core": "^7.0.3"
59
+ "@mikro-orm/core": "^7.0.4"
60
60
  },
61
61
  "peerDependencies": {
62
- "@mikro-orm/core": "7.0.4-dev.9"
62
+ "@mikro-orm/core": "7.0.4"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">= 22.17.0"
package/raw.d.ts CHANGED
@@ -2,11 +2,11 @@ import { type AnyString, type Dictionary, type EntityKey, type RawQueryFragment
2
2
  import type { SelectQueryBuilder as KyselySelectQueryBuilder } from 'kysely';
3
3
  /** @internal Type for QueryBuilder instances passed to raw() - uses toRaw to distinguish from Kysely QueryBuilder */
4
4
  type QueryBuilderLike = {
5
- toQuery(): {
6
- sql: string;
7
- params: readonly unknown[];
8
- };
9
- toRaw(): RawQueryFragment;
5
+ toQuery(): {
6
+ sql: string;
7
+ params: readonly unknown[];
8
+ };
9
+ toRaw(): RawQueryFragment;
10
10
  };
11
11
  /**
12
12
  * Creates raw SQL query fragment that can be assigned to a property or part of a filter. This fragment is represented
@@ -63,5 +63,15 @@ type QueryBuilderLike = {
63
63
  * export class Author { ... }
64
64
  * ```
65
65
  */
66
- export declare function raw<R = RawQueryFragment & symbol, T extends object = any>(sql: QueryBuilderLike | KyselySelectQueryBuilder<any, any, any> | EntityKey<T> | EntityKey<T>[] | AnyString | ((alias: string) => string) | RawQueryFragment, params?: readonly unknown[] | Dictionary<unknown>): R;
66
+ export declare function raw<R = RawQueryFragment & symbol, T extends object = any>(
67
+ sql:
68
+ | QueryBuilderLike
69
+ | KyselySelectQueryBuilder<any, any, any>
70
+ | EntityKey<T>
71
+ | EntityKey<T>[]
72
+ | AnyString
73
+ | ((alias: string) => string)
74
+ | RawQueryFragment,
75
+ params?: readonly unknown[] | Dictionary<unknown>,
76
+ ): R;
67
77
  export {};
package/raw.js CHANGED
@@ -1,4 +1,4 @@
1
- import { raw as raw_, Utils, } from '@mikro-orm/sql';
1
+ import { raw as raw_, Utils } from '@mikro-orm/sql';
2
2
  /**
3
3
  * Creates raw SQL query fragment that can be assigned to a property or part of a filter. This fragment is represented
4
4
  * by `RawQueryFragment` class instance that can be serialized to a string, so it can be used both as an object value
@@ -55,10 +55,10 @@ import { raw as raw_, Utils, } from '@mikro-orm/sql';
55
55
  * ```
56
56
  */
57
57
  export function raw(sql, params) {
58
- if (Utils.isObject(sql) && 'compile' in sql) {
59
- const query = sql.compile();
60
- const processed = query.sql.replaceAll(/\$\d+/g, '?');
61
- return raw_(processed, query.parameters);
62
- }
63
- return raw_(sql, params);
58
+ if (Utils.isObject(sql) && 'compile' in sql) {
59
+ const query = sql.compile();
60
+ const processed = query.sql.replaceAll(/\$\d+/g, '?');
61
+ return raw_(processed, query.parameters);
62
+ }
63
+ return raw_(sql, params);
64
64
  }