spice-js 2.6.36 → 2.6.38
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/build/models/SpiceModel.js +7 -5
- package/build/utility/fix.js +33 -0
- package/package.json +1 -1
- package/src/models/SpiceModel.js +4 -3
- package/src/utility/fix.js +15 -0
|
@@ -9,6 +9,8 @@ var _ResourceLifecycleTriggered = _interopRequireDefault(require("../events/even
|
|
|
9
9
|
|
|
10
10
|
var _Security = require("../utility/Security");
|
|
11
11
|
|
|
12
|
+
var _fix = require("../utility/fix");
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -883,7 +885,7 @@ class SpiceModel {
|
|
|
883
885
|
|
|
884
886
|
return _asyncToGenerator(function* () {
|
|
885
887
|
try {
|
|
886
|
-
var _args4, _args5, _args6
|
|
888
|
+
var _args4, _args5, _args6;
|
|
887
889
|
|
|
888
890
|
if (!args) {
|
|
889
891
|
args = {};
|
|
@@ -1014,18 +1016,18 @@ class SpiceModel {
|
|
|
1014
1016
|
|
|
1015
1017
|
_.each(nestings, nesting => {
|
|
1016
1018
|
if (nesting.type == _2.DataType.ARRAY || nesting.type == Array || nesting.type == "array") {
|
|
1017
|
-
joinSection += "NEST `" + nesting.reference + "` AS `" + nesting.alias + "` ON KEYS `" + that.type + "`.`" + nesting.alias + "` ";
|
|
1019
|
+
joinSection += "NEST `" + (0, _fix.fixCollection)(nesting.reference) + "` AS `" + nesting.alias + "` ON KEYS `" + that.type + "`.`" + nesting.alias + "` ";
|
|
1018
1020
|
} else {
|
|
1019
|
-
joinSection += "LEFT JOIN `" + nesting.reference + "` AS `" + nesting.alias + "` ON KEYS `" + that.type + "`.`" + nesting.alias + "` ";
|
|
1021
|
+
joinSection += "LEFT JOIN `" + (0, _fix.fixCollection)(nesting.reference) + "` AS `" + nesting.alias + "` ON KEYS `" + that.type + "`.`" + nesting.alias + "` ";
|
|
1020
1022
|
}
|
|
1021
1023
|
});
|
|
1022
1024
|
|
|
1023
1025
|
return joinSection;
|
|
1024
1026
|
}
|
|
1025
1027
|
|
|
1026
|
-
var _join = createJoinSection(mappedNestings);
|
|
1028
|
+
var _join = createJoinSection(mappedNestings); //console.log("Props", that.type, nestings, _join, args?.query);
|
|
1029
|
+
|
|
1027
1030
|
|
|
1028
|
-
console.log("Props", that.type, nestings, _join, (_args7 = args) == null ? void 0 : _args7.query);
|
|
1029
1031
|
args._join = _join;
|
|
1030
1032
|
|
|
1031
1033
|
if (args.is_full_text && args.is_full_text === "true" || args.is_custom_query && args.is_custom_query === "true") {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.fixCollection = fixCollection;
|
|
5
|
+
exports.unFixCollection = unFixCollection;
|
|
6
|
+
|
|
7
|
+
function fixCollection(collection) {
|
|
8
|
+
if (collection === void 0) {
|
|
9
|
+
collection = "";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
collection = collection.toLowerCase();
|
|
13
|
+
|
|
14
|
+
if (collection == "usergroup") {
|
|
15
|
+
return "user_group";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return collection;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function unFixCollection(collection) {
|
|
22
|
+
if (collection === void 0) {
|
|
23
|
+
collection = "";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
collection = collection.toLowerCase();
|
|
27
|
+
|
|
28
|
+
if (collection == "user_group") {
|
|
29
|
+
return "usergroup";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return collection;
|
|
33
|
+
}
|
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -5,6 +5,7 @@ let co = require("co");
|
|
|
5
5
|
var regeneratorRuntime = require("regenerator-runtime");
|
|
6
6
|
import ResourceLifecycleTriggered from "../events/events/ResourceLifecycleTriggered";
|
|
7
7
|
import { hasSQLInjection } from "../utility/Security";
|
|
8
|
+
import { fixCollection } from "../utility/fix";
|
|
8
9
|
|
|
9
10
|
var SDate = require("sonover-date"),
|
|
10
11
|
UUID = require("uuid"),
|
|
@@ -917,15 +918,15 @@ export default class SpiceModel {
|
|
|
917
918
|
nesting.type == Array ||
|
|
918
919
|
nesting.type == "array"
|
|
919
920
|
) {
|
|
920
|
-
joinSection += `NEST \`${nesting.reference}\` AS \`${nesting.alias}\` ON KEYS \`${that.type}\`.\`${nesting.alias}\` `;
|
|
921
|
+
joinSection += `LEFT NEST \`${fixCollection(nesting.reference)}\` AS \`${nesting.alias}\` ON KEYS \`${that.type}\`.\`${nesting.alias}\` `;
|
|
921
922
|
} else {
|
|
922
|
-
joinSection += `LEFT JOIN \`${nesting.reference}\` AS \`${nesting.alias}\` ON KEYS \`${that.type}\`.\`${nesting.alias}\` `;
|
|
923
|
+
joinSection += `LEFT JOIN \`${fixCollection(nesting.reference)}\` AS \`${nesting.alias}\` ON KEYS \`${that.type}\`.\`${nesting.alias}\` `;
|
|
923
924
|
}
|
|
924
925
|
});
|
|
925
926
|
return joinSection;
|
|
926
927
|
}
|
|
927
928
|
let _join = createJoinSection(mappedNestings);
|
|
928
|
-
console.log("Props", that.type, nestings, _join, args?.query);
|
|
929
|
+
//console.log("Props", that.type, nestings, _join, args?.query);
|
|
929
930
|
|
|
930
931
|
args._join = _join;
|
|
931
932
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function fixCollection(collection = "") {
|
|
2
|
+
collection = collection.toLowerCase();
|
|
3
|
+
if (collection == "usergroup") {
|
|
4
|
+
return "user_group";
|
|
5
|
+
}
|
|
6
|
+
return collection;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function unFixCollection(collection = "") {
|
|
10
|
+
collection = collection.toLowerCase();
|
|
11
|
+
if (collection == "user_group") {
|
|
12
|
+
return "usergroup";
|
|
13
|
+
}
|
|
14
|
+
return collection;
|
|
15
|
+
}
|