@mikro-orm/postgresql 6.2.10-dev.5 → 6.2.10-dev.50

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.
@@ -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;
@@ -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 mapReferencialIntegrity(value) {
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 = mapReferencialIntegrity(fk.update_rule);
206
- fk.delete_rule = mapReferencialIntegrity(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.5",
3
+ "version": "6.2.10-dev.50",
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.5",
62
- "pg": "8.11.5",
61
+ "@mikro-orm/knex": "6.2.10-dev.50",
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.5"
71
+ "@mikro-orm/core": "6.2.10-dev.50"
72
72
  }
73
73
  }