oak-db 1.0.3 → 1.0.5
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/lib/MySQL/store.js +15 -4
- package/lib/sqlTranslator.js +12 -7
- package/package.json +4 -4
package/lib/MySQL/store.js
CHANGED
|
@@ -44,12 +44,23 @@ var MysqlStore = /** @class */ (function (_super) {
|
|
|
44
44
|
if (i !== -1) {
|
|
45
45
|
var attrHead = attr.slice(0, i);
|
|
46
46
|
var attrTail = attr.slice(i + 1);
|
|
47
|
-
if (!r[attrHead]) {
|
|
48
|
-
r[attrHead] = {};
|
|
49
|
-
}
|
|
50
47
|
var rel = (0, relation_1.judgeRelation)(schema, entity2, attrHead);
|
|
51
48
|
(0, assert_1.default)(rel === 2 || typeof rel === 'string');
|
|
52
|
-
|
|
49
|
+
if (rel === 2) {
|
|
50
|
+
if (r.entity === attrHead) {
|
|
51
|
+
if (!r[attrHead]) {
|
|
52
|
+
r[attrHead] = {};
|
|
53
|
+
}
|
|
54
|
+
resolveAttribute(attrHead, r[attrHead], attrTail, value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(0, assert_1.default)(typeof rel === 'string');
|
|
59
|
+
if (!r[attrHead]) {
|
|
60
|
+
r[attrHead] = {};
|
|
61
|
+
}
|
|
62
|
+
resolveAttribute(rel, r[attrHead], attrTail, value);
|
|
63
|
+
}
|
|
53
64
|
}
|
|
54
65
|
else if (attributes[attr]) {
|
|
55
66
|
var type = attributes[attr].type;
|
package/lib/sqlTranslator.js
CHANGED
|
@@ -183,6 +183,14 @@ var SqlTranslator = /** @class */ (function () {
|
|
|
183
183
|
alias: alias,
|
|
184
184
|
}); });
|
|
185
185
|
}
|
|
186
|
+
else if (['$not'].includes(op)) {
|
|
187
|
+
analyzeFilterNode({
|
|
188
|
+
node: node[op],
|
|
189
|
+
path: path,
|
|
190
|
+
entityName: entityName,
|
|
191
|
+
alias: alias,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
186
194
|
else {
|
|
187
195
|
var rel = (0, relation_1.judgeRelation)(_this.schema, entityName, op);
|
|
188
196
|
if (typeof rel === 'string') {
|
|
@@ -213,8 +221,7 @@ var SqlTranslator = /** @class */ (function () {
|
|
|
213
221
|
(0, lodash_1.assign)(aliasDict, (_b = {},
|
|
214
222
|
_b[pathAttr] = alias2,
|
|
215
223
|
_b));
|
|
216
|
-
from += " left join `".concat(_this.getStorageName(op), "` `").concat(alias2, "` on `").concat(alias, "`.`entityId` = `").concat(alias2, "`.`id`");
|
|
217
|
-
extraWhere += "`".concat(alias, "`.`entity` = '").concat(op, "'");
|
|
224
|
+
from += " left join `".concat(_this.getStorageName(op), "` `").concat(alias2, "` on `").concat(alias, "`.`entityId` = `").concat(alias2, "`.`id` and `").concat(alias, "`.`entity` = '").concat(op, "'");
|
|
218
225
|
}
|
|
219
226
|
else {
|
|
220
227
|
alias2 = aliasDict[pathAttr];
|
|
@@ -222,7 +229,7 @@ var SqlTranslator = /** @class */ (function () {
|
|
|
222
229
|
analyzeFilterNode({
|
|
223
230
|
node: node[op],
|
|
224
231
|
path: pathAttr,
|
|
225
|
-
entityName:
|
|
232
|
+
entityName: op,
|
|
226
233
|
alias: alias2,
|
|
227
234
|
});
|
|
228
235
|
}
|
|
@@ -280,8 +287,7 @@ var SqlTranslator = /** @class */ (function () {
|
|
|
280
287
|
(0, lodash_1.assign)(aliasDict, (_c = {},
|
|
281
288
|
_c[pathAttr] = alias2,
|
|
282
289
|
_c));
|
|
283
|
-
from += " left join `".concat(_this.getStorageName(attr), "` `").concat(alias2, "` on `").concat(alias, "`.`entityId` = `").concat(alias2, "`.`id`");
|
|
284
|
-
extraWhere += "`".concat(alias, "`.`entity` = '").concat(attr, "'");
|
|
290
|
+
from += " left join `".concat(_this.getStorageName(attr), "` `").concat(alias2, "` on `").concat(alias, "`.`entityId` = `").concat(alias2, "`.`id` and `").concat(alias, "`.`entity` = '").concat(attr, "'");
|
|
285
291
|
}
|
|
286
292
|
else {
|
|
287
293
|
alias2 = aliasDict[pathAttr];
|
|
@@ -342,7 +348,7 @@ var SqlTranslator = /** @class */ (function () {
|
|
|
342
348
|
(0, lodash_1.assign)(aliasDict, (_b = {},
|
|
343
349
|
_b[pathAttr] = alias2,
|
|
344
350
|
_b));
|
|
345
|
-
from += " left join `".concat(_this.getStorageName(attr), "` `").concat(alias2, "` on `").concat(alias, "`.`entityId` = `").concat(alias2, "`.`id`");
|
|
351
|
+
from += " left join `".concat(_this.getStorageName(attr), "` `").concat(alias2, "` on `").concat(alias, "`.`entityId` = `").concat(alias2, "`.`id` and `").concat(alias, "`.`entity` = '").concat(attr, "'");
|
|
346
352
|
}
|
|
347
353
|
else {
|
|
348
354
|
alias2 = aliasDict[pathAttr];
|
|
@@ -353,7 +359,6 @@ var SqlTranslator = /** @class */ (function () {
|
|
|
353
359
|
entityName: attr,
|
|
354
360
|
alias: alias2,
|
|
355
361
|
});
|
|
356
|
-
extraWhere += "`".concat(alias, "`.`entity` = '").concat(attr, "'");
|
|
357
362
|
}
|
|
358
363
|
});
|
|
359
364
|
if (node['#id']) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-db",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "oak-db",
|
|
5
|
-
"main": "lib/index
|
|
5
|
+
"main": "lib/index",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "XuChang"
|
|
8
8
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"luxon": "^2.4.0",
|
|
20
20
|
"mysql": "^2.18.1",
|
|
21
21
|
"mysql2": "^2.3.3",
|
|
22
|
-
"oak-domain": "1.1.
|
|
22
|
+
"oak-domain": "^1.1.12",
|
|
23
23
|
"uuid": "^8.3.2"
|
|
24
24
|
},
|
|
25
25
|
"license": "ISC",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/node": "^17.0.42",
|
|
31
31
|
"@types/uuid": "^8.3.4",
|
|
32
32
|
"mocha": "^10.0.0",
|
|
33
|
-
"oak-general-business": "1.0.13",
|
|
33
|
+
"oak-general-business": "^1.0.13",
|
|
34
34
|
"ts-node": "~10.9.1",
|
|
35
35
|
"tslib": "^2.4.0",
|
|
36
36
|
"typescript": "~4.7.4"
|