@mikro-orm/postgresql 7.1.0-dev.30 → 7.1.0-dev.31
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.
- package/PostgreSqlConnection.js +4 -14
- package/PostgreSqlEntityManager.d.ts +2 -13
- package/PostgreSqlEntityManager.js +2 -19
- package/PostgreSqlPlatform.d.ts +0 -1
- package/PostgreSqlPlatform.js +0 -19
- package/README.md +2 -1
- package/package.json +4 -4
package/PostgreSqlConnection.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Pool, TypeOverrides } from 'pg';
|
|
|
2
2
|
import Cursor from 'pg-cursor';
|
|
3
3
|
import { PostgresDialect } from 'kysely';
|
|
4
4
|
import array from 'postgres-array';
|
|
5
|
-
import { AbstractSqlConnection, Utils } from '@mikro-orm/sql';
|
|
5
|
+
import { AbstractSqlConnection, createPostgreSqlTypeParsers, Utils } from '@mikro-orm/sql';
|
|
6
6
|
/** PostgreSQL database connection using the `pg` driver. */
|
|
7
7
|
export class PostgreSqlConnection extends AbstractSqlConnection {
|
|
8
8
|
createKyselyDialect(overrides) {
|
|
@@ -18,20 +18,10 @@ export class PostgreSqlConnection extends AbstractSqlConnection {
|
|
|
18
18
|
const pool = this.config.get('pool');
|
|
19
19
|
Utils.defaultValue(ret, 'max', pool?.max);
|
|
20
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
21
|
const types = new TypeOverrides();
|
|
23
|
-
[
|
|
24
|
-
|
|
25
|
-
|
|
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)));
|
|
22
|
+
for (const [oid, parser] of Object.entries(createPostgreSqlTypeParsers(s => array.parse(s)))) {
|
|
23
|
+
types.setTypeParser(Number(oid), parser);
|
|
24
|
+
}
|
|
35
25
|
ret.types = types;
|
|
36
26
|
return Utils.mergeConfig(ret, overrides);
|
|
37
27
|
}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SqlEntityManager } from '@mikro-orm/sql';
|
|
1
|
+
import { BasePostgreSqlEntityManager } from '@mikro-orm/sql';
|
|
3
2
|
import type { PostgreSqlDriver } from './PostgreSqlDriver.js';
|
|
4
3
|
/**
|
|
5
4
|
* @inheritDoc
|
|
6
5
|
*/
|
|
7
|
-
export declare class PostgreSqlEntityManager<Driver extends PostgreSqlDriver = PostgreSqlDriver> extends
|
|
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>;
|
|
6
|
+
export declare class PostgreSqlEntityManager<Driver extends PostgreSqlDriver = PostgreSqlDriver> extends BasePostgreSqlEntityManager<Driver> {
|
|
18
7
|
}
|
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BasePostgreSqlEntityManager } from '@mikro-orm/sql';
|
|
2
2
|
/**
|
|
3
3
|
* @inheritDoc
|
|
4
4
|
*/
|
|
5
|
-
export class PostgreSqlEntityManager extends
|
|
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
|
-
}
|
|
5
|
+
export class PostgreSqlEntityManager extends BasePostgreSqlEntityManager {
|
|
23
6
|
}
|
package/PostgreSqlPlatform.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export declare class PostgreSqlPlatform extends BasePostgreSqlPlatform {
|
|
|
5
5
|
convertIntervalToJSValue(value: string): unknown;
|
|
6
6
|
convertIntervalToDatabaseValue(value: IPostgresInterval): unknown;
|
|
7
7
|
unmarshallArray(value: string): string[];
|
|
8
|
-
escape(value: any): string;
|
|
9
8
|
/**
|
|
10
9
|
* @inheritDoc
|
|
11
10
|
*/
|
package/PostgreSqlPlatform.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Client } from 'pg';
|
|
2
1
|
import array from 'postgres-array';
|
|
3
2
|
import parseDate from 'postgres-date';
|
|
4
3
|
import PostgresInterval from 'postgres-interval';
|
|
@@ -17,24 +16,6 @@ export class PostgreSqlPlatform extends BasePostgreSqlPlatform {
|
|
|
17
16
|
unmarshallArray(value) {
|
|
18
17
|
return array.parse(value);
|
|
19
18
|
}
|
|
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
19
|
/**
|
|
39
20
|
* @inheritDoc
|
|
40
21
|
*/
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a href="https://mikro-orm.io"><img src="https://raw.githubusercontent.com/mikro-orm/mikro-orm/master/docs/static/img/logo-readme.svg?sanitize=true" alt="MikroORM" /></a>
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
-
TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-orm.io/docs/unit-of-work/) and [Identity Map](https://mikro-orm.io/docs/identity-map/) patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL, SQLite (including libSQL), MSSQL and Oracle databases.
|
|
5
|
+
TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-orm.io/docs/unit-of-work/) and [Identity Map](https://mikro-orm.io/docs/identity-map/) patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL (including CockroachDB and PGlite), SQLite (including libSQL), MSSQL and Oracle databases.
|
|
6
6
|
|
|
7
7
|
> Heavily inspired by [Doctrine](https://www.doctrine-project.org/) and [Hibernate](https://hibernate.org/).
|
|
8
8
|
|
|
@@ -19,6 +19,7 @@ Install a driver package for your database:
|
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
21
|
npm install @mikro-orm/postgresql # PostgreSQL
|
|
22
|
+
npm install @mikro-orm/pglite # PGlite (embedded PostgreSQL in WASM)
|
|
22
23
|
npm install @mikro-orm/mysql # MySQL
|
|
23
24
|
npm install @mikro-orm/mariadb # MariaDB
|
|
24
25
|
npm install @mikro-orm/sqlite # SQLite
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/postgresql",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.31",
|
|
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,8 +47,8 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.1.0-dev.
|
|
51
|
-
"kysely": "0.
|
|
50
|
+
"@mikro-orm/sql": "7.1.0-dev.31",
|
|
51
|
+
"kysely": "0.29.0",
|
|
52
52
|
"pg": "8.20.0",
|
|
53
53
|
"pg-cursor": "2.19.0",
|
|
54
54
|
"postgres-array": "3.0.4",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@mikro-orm/core": "^7.0.15"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
62
|
+
"@mikro-orm/core": "7.1.0-dev.31"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">= 22.17.0"
|