@mikro-orm/sql 7.2.13-dev.2 → 7.2.13-dev.3
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/package.json +2 -2
- package/query/QueryBuilderHelper.js +21 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.13-dev.
|
|
3
|
+
"version": "7.2.13-dev.3",
|
|
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.2.12"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.13-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.13-dev.3"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
|
@@ -568,6 +568,15 @@ export class QueryBuilderHelper {
|
|
|
568
568
|
['$in', '$nin'].includes(op) &&
|
|
569
569
|
Array.isArray(value[op]) &&
|
|
570
570
|
value[op].every((v) => Array.isArray(v));
|
|
571
|
+
// `in` and `not in` never match null, so a null in the list becomes an explicit null check
|
|
572
|
+
if (fields.length === 1 && ['$in', '$nin'].includes(op) && Array.isArray(value[op]) && value[op].includes(null)) {
|
|
573
|
+
const list = value[op].filter((v) => v !== null);
|
|
574
|
+
const conds = [{ [key]: { [op === '$in' ? '$eq' : '$ne']: null } }];
|
|
575
|
+
if (list.length > 0) {
|
|
576
|
+
conds.unshift({ [key]: { [op]: list } });
|
|
577
|
+
}
|
|
578
|
+
return this.appendGroupCondition(type, op === '$in' ? '$or' : '$and', conds);
|
|
579
|
+
}
|
|
571
580
|
// an empty list falls through to the generic `1 = 0` / `1 = 1` handling below
|
|
572
581
|
if (fields.length > 1 && Array.isArray(value[op]) && value[op].length > 0) {
|
|
573
582
|
const singleTuple = !value[op].every((v) => Array.isArray(v));
|
|
@@ -997,8 +1006,14 @@ export class QueryBuilderHelper {
|
|
|
997
1006
|
parts.push(`1 = ${op === '$in' ? 0 : 1}`);
|
|
998
1007
|
}
|
|
999
1008
|
else {
|
|
1000
|
-
val.
|
|
1001
|
-
|
|
1009
|
+
const list = val.filter((v) => v !== null);
|
|
1010
|
+
const conds = list.length > 0 ? [`${lhs} ${replacement} (${list.map(() => '?').join(', ')})`] : [];
|
|
1011
|
+
list.forEach((v) => params.push(v));
|
|
1012
|
+
// `in` and `not in` never match null, so a null in the list becomes an explicit null check
|
|
1013
|
+
if (list.length < val.length) {
|
|
1014
|
+
conds.push(`${lhs} is ${op === '$in' ? '' : 'not '}null`);
|
|
1015
|
+
}
|
|
1016
|
+
parts.push(conds.length > 1 ? `(${conds.join(op === '$in' ? ' or ' : ' and ')})` : conds[0]);
|
|
1002
1017
|
}
|
|
1003
1018
|
}
|
|
1004
1019
|
else if (op === '$exists') {
|
|
@@ -1102,11 +1117,12 @@ export class QueryBuilderHelper {
|
|
|
1102
1117
|
if (typeof v === 'bigint') {
|
|
1103
1118
|
return 'bigint';
|
|
1104
1119
|
}
|
|
1105
|
-
if (Array.isArray(v)
|
|
1106
|
-
|
|
1120
|
+
if (Array.isArray(v)) {
|
|
1121
|
+
const first = v.find(i => i !== null);
|
|
1122
|
+
if (typeof first === 'number') {
|
|
1107
1123
|
return 'number';
|
|
1108
1124
|
}
|
|
1109
|
-
if (typeof
|
|
1125
|
+
if (typeof first === 'boolean') {
|
|
1110
1126
|
return 'boolean';
|
|
1111
1127
|
}
|
|
1112
1128
|
}
|