electrodb 2.10.5 → 2.10.6
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 +1 -1
- package/src/entity.js +8 -4
- package/src/operations.js +14 -0
package/package.json
CHANGED
package/src/entity.js
CHANGED
|
@@ -1014,13 +1014,17 @@ class Entity {
|
|
|
1014
1014
|
|
|
1015
1015
|
return { data: results };
|
|
1016
1016
|
} catch (err) {
|
|
1017
|
-
if (
|
|
1017
|
+
if (
|
|
1018
|
+
config.originalErr ||
|
|
1019
|
+
stackTrace === undefined ||
|
|
1020
|
+
err.isElectroError
|
|
1021
|
+
) {
|
|
1018
1022
|
throw err;
|
|
1019
1023
|
} else {
|
|
1020
1024
|
const error = new e.ElectroError(
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1025
|
+
e.ErrorCodes.AWSError,
|
|
1026
|
+
err.message,
|
|
1027
|
+
err,
|
|
1024
1028
|
);
|
|
1025
1029
|
error.stack = stackTrace;
|
|
1026
1030
|
|
package/src/operations.js
CHANGED
|
@@ -28,8 +28,21 @@ class ExpressionState {
|
|
|
28
28
|
return `${this.prefix}${this.counts[name]++}`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
formatName(name = "") {
|
|
32
|
+
const nameWasNotANumber = isNaN(name);
|
|
33
|
+
name = `${name}`.replaceAll(/[^\w]/g, "");
|
|
34
|
+
if (name.length === 0) {
|
|
35
|
+
name = "p";
|
|
36
|
+
} else if (nameWasNotANumber !== isNaN(name)) {
|
|
37
|
+
// name became number due to replace
|
|
38
|
+
name = `p${name}`;
|
|
39
|
+
}
|
|
40
|
+
return name;
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
// todo: make the structure: name, value, paths
|
|
32
44
|
setName(paths, name, value) {
|
|
45
|
+
name = this.formatName(name);
|
|
33
46
|
let json = "";
|
|
34
47
|
let expression = "";
|
|
35
48
|
const prop = `#${name}`;
|
|
@@ -53,6 +66,7 @@ class ExpressionState {
|
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
setValue(name, value) {
|
|
69
|
+
name = this.formatName(name);
|
|
56
70
|
let valueCount = this.incrementName(name);
|
|
57
71
|
let expression = `:${name}${valueCount}`;
|
|
58
72
|
this.values[expression] = value;
|