@mikro-orm/sql 7.0.7-dev.20 → 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.
@@ -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
- sql +=
904
- pks.length > 1
905
- ? `(${pks.map(pk => this.platform.quoteIdentifier(pk)).join(', ')})`
906
- : this.platform.quoteIdentifier(pks[0]);
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 `(${Array.from({ length: pks.length }).fill('?').join(', ')})`;
920
+ return condTemplate;
921
921
  }
922
922
  params.push(cond);
923
923
  return '?';
924
924
  });
925
- sql += ` in (${conds.join(', ')})`;
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.20",
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.20"
56
+ "@mikro-orm/core": "7.0.7-dev.22"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"