@mikro-orm/postgresql 6.2.10-dev.6 → 6.2.10-dev.61
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/PostgreSqlMikroORM.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PostgreSqlMikroORM = void 0;
|
|
4
|
+
exports.definePostgreSqlConfig = definePostgreSqlConfig;
|
|
4
5
|
const core_1 = require("@mikro-orm/core");
|
|
5
6
|
const PostgreSqlDriver_1 = require("./PostgreSqlDriver");
|
|
6
7
|
/**
|
|
@@ -26,4 +27,3 @@ exports.PostgreSqlMikroORM = PostgreSqlMikroORM;
|
|
|
26
27
|
function definePostgreSqlConfig(options) {
|
|
27
28
|
return (0, core_1.defineConfig)({ driver: PostgreSqlDriver_1.PostgreSqlDriver, ...options });
|
|
28
29
|
}
|
|
29
|
-
exports.definePostgreSqlConfig = definePostgreSqlConfig;
|
package/PostgreSqlPlatform.d.ts
CHANGED
|
@@ -10,12 +10,6 @@ export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
10
10
|
usesCascadeStatement(): boolean;
|
|
11
11
|
supportsNativeEnums(): boolean;
|
|
12
12
|
supportsCustomPrimaryKeyNames(): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Postgres will complain if we try to batch update uniquely constrained property (moving the value from one entity to another).
|
|
15
|
-
* This flag will result in postponing 1:1 updates (removing them from the batched query).
|
|
16
|
-
* @see https://stackoverflow.com/questions/5403437/atomic-multi-row-update-with-a-unique-constraint
|
|
17
|
-
*/
|
|
18
|
-
allowsUniqueBatchUpdates(): boolean;
|
|
19
13
|
getCurrentTimestampSQL(length: number): string;
|
|
20
14
|
getDateTimeTypeDeclarationSQL(column: {
|
|
21
15
|
length?: number;
|
package/PostgreSqlPlatform.js
CHANGED
|
@@ -27,14 +27,6 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
27
27
|
supportsCustomPrimaryKeyNames() {
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Postgres will complain if we try to batch update uniquely constrained property (moving the value from one entity to another).
|
|
32
|
-
* This flag will result in postponing 1:1 updates (removing them from the batched query).
|
|
33
|
-
* @see https://stackoverflow.com/questions/5403437/atomic-multi-row-update-with-a-unique-constraint
|
|
34
|
-
*/
|
|
35
|
-
allowsUniqueBatchUpdates() {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
30
|
getCurrentTimestampSQL(length) {
|
|
39
31
|
return `current_timestamp(${length})`;
|
|
40
32
|
}
|
|
@@ -26,6 +26,7 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
26
26
|
+ `from information_schema.tables `
|
|
27
27
|
+ `where ${this.getIgnoredNamespacesConditionSQL('table_schema')} `
|
|
28
28
|
+ `and table_name != 'geometry_columns' and table_name != 'spatial_ref_sys' and table_type != 'VIEW' `
|
|
29
|
+
+ `and table_name not in (select inhrelid::regclass::text from pg_inherits) `
|
|
29
30
|
+ `order by table_name`;
|
|
30
31
|
}
|
|
31
32
|
async getNamespaces(connection) {
|
|
@@ -178,7 +179,8 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
178
179
|
async getAllForeignKeys(connection, tables) {
|
|
179
180
|
const sql = `select nsp1.nspname schema_name, cls1.relname table_name, nsp2.nspname referenced_schema_name,
|
|
180
181
|
cls2.relname referenced_table_name, a.attname column_name, af.attname referenced_column_name, conname constraint_name,
|
|
181
|
-
confupdtype update_rule, confdeltype delete_rule, array_position(con.conkey,a.attnum) as ord, condeferrable, condeferred
|
|
182
|
+
confupdtype update_rule, confdeltype delete_rule, array_position(con.conkey,a.attnum) as ord, condeferrable, condeferred,
|
|
183
|
+
pg_get_constraintdef(con.oid) as constraint_def
|
|
182
184
|
from pg_attribute a
|
|
183
185
|
join pg_constraint con on con.conrelid = a.attrelid AND a.attnum = ANY (con.conkey)
|
|
184
186
|
join pg_attribute af on af.attnum = con.confkey[array_position(con.conkey,a.attnum)] AND af.attrelid = con.confrelid
|
|
@@ -191,7 +193,11 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
191
193
|
order by nsp1.nspname, cls1.relname, constraint_name, ord`;
|
|
192
194
|
const allFks = await connection.execute(sql);
|
|
193
195
|
const ret = {};
|
|
194
|
-
function
|
|
196
|
+
function mapReferentialIntegrity(value, def) {
|
|
197
|
+
const match = ['n', 'd'].includes(value) && def.match(/ON DELETE (SET (NULL|DEFAULT) \(.*?\))/);
|
|
198
|
+
if (match) {
|
|
199
|
+
return match[1];
|
|
200
|
+
}
|
|
195
201
|
switch (value) {
|
|
196
202
|
case 'r': return 'RESTRICT';
|
|
197
203
|
case 'c': return 'CASCADE';
|
|
@@ -202,8 +208,8 @@ class PostgreSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
|
202
208
|
}
|
|
203
209
|
}
|
|
204
210
|
for (const fk of allFks) {
|
|
205
|
-
fk.update_rule =
|
|
206
|
-
fk.delete_rule =
|
|
211
|
+
fk.update_rule = mapReferentialIntegrity(fk.update_rule, fk.constraint_def);
|
|
212
|
+
fk.delete_rule = mapReferentialIntegrity(fk.delete_rule, fk.constraint_def);
|
|
207
213
|
if (fk.condeferrable) {
|
|
208
214
|
fk.defer_mode = fk.condeferred ? core_1.DeferMode.INITIALLY_DEFERRED : core_1.DeferMode.INITIALLY_IMMEDIATE;
|
|
209
215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/postgresql",
|
|
3
|
-
"version": "6.2.10-dev.
|
|
3
|
+
"version": "6.2.10-dev.61",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@mikro-orm/knex": "6.2.10-dev.
|
|
62
|
-
"pg": "8.
|
|
61
|
+
"@mikro-orm/knex": "6.2.10-dev.61",
|
|
62
|
+
"pg": "8.12.0",
|
|
63
63
|
"postgres-array": "3.0.2",
|
|
64
64
|
"postgres-date": "2.1.0",
|
|
65
65
|
"postgres-interval": "4.0.2"
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"@mikro-orm/core": "^6.2.9"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@mikro-orm/core": "6.2.10-dev.
|
|
71
|
+
"@mikro-orm/core": "6.2.10-dev.61"
|
|
72
72
|
}
|
|
73
73
|
}
|