@mikro-orm/sql 7.0.7-dev.21 → 7.0.7-dev.22
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 +15 -6
- package/package.json +2 -2
package/AbstractSqlDriver.js
CHANGED
|
@@ -900,10 +900,10 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
900
900
|
sql = sql.substring(0, sql.length - 2) + ' where ';
|
|
901
901
|
const pkProps = meta.primaryKeys.concat(...meta.concurrencyCheckKeys);
|
|
902
902
|
const pks = Utils.flatten(pkProps.map(pk => meta.properties[pk].fieldNames));
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
903
|
+
const useTupleIn = pks.length <= 1 || this.platform.allowsComparingTuples();
|
|
904
|
+
const condTemplate = useTupleIn
|
|
905
|
+
? `(${pks.map(() => '?').join(', ')})`
|
|
906
|
+
: `(${pks.map(pk => `${this.platform.quoteIdentifier(pk)} = ?`).join(' and ')})`;
|
|
907
907
|
const conds = where.map(cond => {
|
|
908
908
|
if (Utils.isPlainObject(cond) && Utils.getObjectKeysSize(cond) === 1) {
|
|
909
909
|
cond = Object.values(cond)[0];
|
|
@@ -917,12 +917,21 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
917
917
|
params.push(cond[pk]);
|
|
918
918
|
}
|
|
919
919
|
});
|
|
920
|
-
return
|
|
920
|
+
return condTemplate;
|
|
921
921
|
}
|
|
922
922
|
params.push(cond);
|
|
923
923
|
return '?';
|
|
924
924
|
});
|
|
925
|
-
|
|
925
|
+
if (useTupleIn) {
|
|
926
|
+
sql +=
|
|
927
|
+
pks.length > 1
|
|
928
|
+
? `(${pks.map(pk => this.platform.quoteIdentifier(pk)).join(', ')})`
|
|
929
|
+
: this.platform.quoteIdentifier(pks[0]);
|
|
930
|
+
sql += ` in (${conds.join(', ')})`;
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
sql += conds.join(' or ');
|
|
934
|
+
}
|
|
926
935
|
if (this.platform.usesReturningStatement() && returning.size > 0) {
|
|
927
936
|
const returningFields = Utils.flatten([...returning].map(prop => meta.properties[prop].fieldNames));
|
|
928
937
|
/* v8 ignore next */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.0.7-dev.
|
|
3
|
+
"version": "7.0.7-dev.22",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.0.6"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.0.7-dev.
|
|
56
|
+
"@mikro-orm/core": "7.0.7-dev.22"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|