@mikro-orm/core 6.6.18-dev.2 → 6.6.18-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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.18-dev.
|
|
3
|
+
"version": "6.6.18-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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.3",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.18-dev.
|
|
67
|
+
"mikro-orm": "6.6.18-dev.3",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/types/DecimalType.js
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DecimalType = void 0;
|
|
4
4
|
const Type_1 = require("./Type");
|
|
5
|
+
/** Scales a plain decimal string to an integer rounded half away from zero at `scale`, like the DB does. */
|
|
6
|
+
function toScaledInteger(value, scale) {
|
|
7
|
+
if (typeof value !== 'string') {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const negative = value.startsWith('-');
|
|
11
|
+
const [int, fraction = ''] = (negative ? value.slice(1) : value).split('.');
|
|
12
|
+
const digits = int + fraction;
|
|
13
|
+
for (let i = 0; i < digits.length; i++) {
|
|
14
|
+
const code = digits.charCodeAt(i);
|
|
15
|
+
if (code < 48 || code > 57) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
let scaled = BigInt('0' + int + fraction.slice(0, scale).padEnd(scale, '0'));
|
|
20
|
+
if (fraction.charCodeAt(scale) >= 53) {
|
|
21
|
+
scaled++;
|
|
22
|
+
}
|
|
23
|
+
return negative ? -scaled : scaled;
|
|
24
|
+
}
|
|
5
25
|
/**
|
|
6
26
|
* Type that maps an SQL DECIMAL to a JS string or number.
|
|
7
27
|
*/
|
|
@@ -18,7 +38,20 @@ class DecimalType extends Type_1.Type {
|
|
|
18
38
|
return String(value);
|
|
19
39
|
}
|
|
20
40
|
compareValues(a, b) {
|
|
21
|
-
|
|
41
|
+
if (a === b) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (this.format(a) !== this.format(b)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const scale = this.prop?.scale;
|
|
48
|
+
// doubles are exact only up to 15 significant digits, so only higher precision strings can differ past the numeric check
|
|
49
|
+
if ((this.prop?.precision ?? 0) <= 15 || this.compareAsType() !== 'string') {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const scaledA = toScaledInteger(a, scale ?? 0);
|
|
53
|
+
const scaledB = toScaledInteger(b, scale ?? 0);
|
|
54
|
+
return scaledA == null || scaledB == null || scaledA === scaledB;
|
|
22
55
|
}
|
|
23
56
|
format(val) {
|
|
24
57
|
/* istanbul ignore next */
|
|
@@ -176,7 +176,7 @@ class ChangeSetPersister {
|
|
|
176
176
|
const tmp = [];
|
|
177
177
|
for (const key of meta.concurrencyCheckKeys) {
|
|
178
178
|
cond[key] = changeSet.originalEntity[key];
|
|
179
|
-
if (changeSet.payload
|
|
179
|
+
if (Object.hasOwn(changeSet.payload, key)) {
|
|
180
180
|
tmp.push(key);
|
|
181
181
|
}
|
|
182
182
|
}
|
package/utils/QueryHelper.js
CHANGED
|
@@ -72,9 +72,16 @@ class QueryHelper {
|
|
|
72
72
|
const op = this.liftGroupOperators(value, prop.targetMeta, metadata, k);
|
|
73
73
|
if (op) {
|
|
74
74
|
delete where[k];
|
|
75
|
-
|
|
75
|
+
const group = value[op].map((v) => {
|
|
76
76
|
return { [k]: v };
|
|
77
77
|
});
|
|
78
|
+
if (op in where) {
|
|
79
|
+
// Sibling groups are conjunctive, even when both use `$or`.
|
|
80
|
+
where.$and = [...(where.$and ?? []), { [op]: group }];
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
where[op] = group;
|
|
84
|
+
}
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
return undefined;
|