@mikro-orm/sql 7.0.0-dev.167 → 7.0.0-dev.169
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/AbstractSqlDriver.js
CHANGED
|
@@ -573,6 +573,9 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
573
573
|
if (options.onConflictAction === 'ignore') {
|
|
574
574
|
qb.ignore();
|
|
575
575
|
}
|
|
576
|
+
if (options.onConflictWhere) {
|
|
577
|
+
qb.where(options.onConflictWhere);
|
|
578
|
+
}
|
|
576
579
|
}
|
|
577
580
|
else {
|
|
578
581
|
qb.update(data).where(where);
|
|
@@ -608,6 +611,9 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
608
611
|
if (options.onConflictAction === 'ignore') {
|
|
609
612
|
qb.ignore();
|
|
610
613
|
}
|
|
614
|
+
if (options.onConflictWhere) {
|
|
615
|
+
qb.where(options.onConflictWhere);
|
|
616
|
+
}
|
|
611
617
|
return this.rethrow(qb.execute('run', false));
|
|
612
618
|
}
|
|
613
619
|
const collections = options.processCollections ? data.map(d => this.extractManyToMany(meta, d)) : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.169",
|
|
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
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"@mikro-orm/core": "^6.6.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
59
|
+
"@mikro-orm/core": "7.0.0-dev.169"
|
|
60
60
|
}
|
|
61
61
|
}
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecimalType, EntitySchema, RawQueryFragment, ReferenceKind, t, Type, UnknownType, Utils, } from '@mikro-orm/core';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
@@ -117,23 +117,9 @@ export class DatabaseTable {
|
|
|
117
117
|
referencedColumnNames: prop.referencedColumnNames,
|
|
118
118
|
referencedTableName: schema ? `${schema}.${prop.referencedTableName}` : prop.referencedTableName,
|
|
119
119
|
};
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
if (prop.updateRule) {
|
|
125
|
-
this.foreignKeys[constraintName].updateRule = prop.updateRule || 'cascade';
|
|
126
|
-
}
|
|
127
|
-
if ((prop.cascade.includes(Cascade.PERSIST) || prop.cascade.includes(Cascade.ALL))) {
|
|
128
|
-
const hasCascadePath = Object.values(this.foreignKeys).some(fk => {
|
|
129
|
-
return fk.constraintName !== constraintName
|
|
130
|
-
&& ((fk.updateRule && fk.updateRule !== 'no action') || (fk.deleteRule && fk.deleteRule !== 'no action'))
|
|
131
|
-
&& fk.referencedTableName === this.foreignKeys[constraintName].referencedTableName;
|
|
132
|
-
});
|
|
133
|
-
if (!hasCascadePath || this.platform.supportsMultipleCascadePaths()) {
|
|
134
|
-
this.foreignKeys[constraintName].updateRule ??= 'cascade';
|
|
135
|
-
}
|
|
136
|
-
}
|
|
120
|
+
const schemaConfig = config.get('schemaGenerator');
|
|
121
|
+
this.foreignKeys[constraintName].deleteRule = prop.deleteRule ?? schemaConfig.defaultDeleteRule;
|
|
122
|
+
this.foreignKeys[constraintName].updateRule = prop.updateRule ?? schemaConfig.defaultUpdateRule;
|
|
137
123
|
if (prop.deferMode) {
|
|
138
124
|
this.foreignKeys[constraintName].deferMode = prop.deferMode;
|
|
139
125
|
}
|
package/schema/SchemaHelper.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export declare abstract class SchemaHelper {
|
|
|
66
66
|
skipTables?: (string | RegExp)[];
|
|
67
67
|
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
68
68
|
managementDbName?: string;
|
|
69
|
+
defaultUpdateRule?: "cascade" | "no action" | "set null" | "set default" | "restrict";
|
|
70
|
+
defaultDeleteRule?: "cascade" | "no action" | "set null" | "set default" | "restrict";
|
|
69
71
|
};
|
|
70
72
|
protected processComment(comment: string): string;
|
|
71
73
|
protected quote(...keys: (string | undefined)[]): string;
|
|
@@ -11,6 +11,8 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
|
|
|
11
11
|
skipTables?: (string | RegExp)[];
|
|
12
12
|
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
13
13
|
managementDbName?: string;
|
|
14
|
+
defaultUpdateRule?: "cascade" | "no action" | "set null" | "set default" | "restrict";
|
|
15
|
+
defaultDeleteRule?: "cascade" | "no action" | "set null" | "set default" | "restrict";
|
|
14
16
|
};
|
|
15
17
|
protected lastEnsuredDatabase?: string;
|
|
16
18
|
static register(orm: MikroORM): void;
|