oak-db 3.3.4 → 3.3.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/lib/MySQL/connector.d.ts +1 -1
- package/lib/MySQL/store.d.ts +36 -36
- package/lib/MySQL/store.js +304 -304
- package/lib/MySQL/translator.js +943 -943
- package/lib/sqlTranslator.js +16 -21
- package/package.json +2 -2
package/lib/sqlTranslator.js
CHANGED
|
@@ -172,10 +172,13 @@ class SqlTranslator {
|
|
|
172
172
|
attrs.forEach((attr, attrIdx) => {
|
|
173
173
|
const attrDef = attributes[attr];
|
|
174
174
|
const { type: dataType } = attrDef;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
sql +=
|
|
175
|
+
// undefined应该不要处理
|
|
176
|
+
if (d[attr] !== undefined) {
|
|
177
|
+
const value = this.translateAttrValue(dataType, d[attr]);
|
|
178
|
+
sql += value;
|
|
179
|
+
if (attrIdx < attrs.length - 1) {
|
|
180
|
+
sql += ',';
|
|
181
|
+
}
|
|
179
182
|
}
|
|
180
183
|
});
|
|
181
184
|
if (dataIndex < data.length - 1) {
|
|
@@ -599,8 +602,8 @@ class SqlTranslator {
|
|
|
599
602
|
*
|
|
600
603
|
* in代表外键连接后至少有一行数据
|
|
601
604
|
* not in代表外键连接后一行也不能有
|
|
602
|
-
* all
|
|
603
|
-
* not all
|
|
605
|
+
* all代表反连接条件的一行也不能有(符合的是否至少要有一行?直觉上没这个限制)
|
|
606
|
+
* not all 代表反连接条件的至少有一行
|
|
604
607
|
*
|
|
605
608
|
* 目前将这种子查询翻译成了exists查询,当外表很大而子查询结果集很小时可能有性能问题,取决于MySQL执行器的能力
|
|
606
609
|
* by Xc 20230726
|
|
@@ -614,7 +617,7 @@ class SqlTranslator {
|
|
|
614
617
|
});
|
|
615
618
|
}
|
|
616
619
|
const fk = foreignKey || 'entityId';
|
|
617
|
-
const joinFilter =
|
|
620
|
+
const joinFilter = {
|
|
618
621
|
$expr12: {
|
|
619
622
|
$eq: [
|
|
620
623
|
{
|
|
@@ -626,29 +629,20 @@ class SqlTranslator {
|
|
|
626
629
|
}
|
|
627
630
|
],
|
|
628
631
|
}
|
|
629
|
-
} : {
|
|
630
|
-
$expr12: {
|
|
631
|
-
$ne: [
|
|
632
|
-
{
|
|
633
|
-
'#attr': fk,
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
'#refId': refAlia2,
|
|
637
|
-
'#refAttr': 'id',
|
|
638
|
-
}
|
|
639
|
-
],
|
|
640
|
-
}
|
|
641
632
|
};
|
|
642
633
|
if (!foreignKey) {
|
|
643
634
|
Object.assign(joinFilter, {
|
|
644
635
|
entity: entity2,
|
|
645
636
|
});
|
|
646
637
|
}
|
|
638
|
+
const conditionalPredicate = ['all', 'not all'].includes(predicate) ? {
|
|
639
|
+
$not: filter2[attr],
|
|
640
|
+
} : filter2[attr];
|
|
647
641
|
const { stmt, currentNumber: ct2 } = this.translateSelectInner(subEntity, {
|
|
648
642
|
data: {
|
|
649
643
|
id: 1,
|
|
650
644
|
},
|
|
651
|
-
filter: (0, filter_1.combineFilters)(subEntity, this.schema, [joinFilter,
|
|
645
|
+
filter: (0, filter_1.combineFilters)(subEntity, this.schema, [joinFilter, conditionalPredicate]),
|
|
652
646
|
indexFrom: 0,
|
|
653
647
|
count: 1,
|
|
654
648
|
}, currentNumber, filterRefAlias, option);
|
|
@@ -928,7 +922,8 @@ class SqlTranslator {
|
|
|
928
922
|
(0, assert_1.default)(!sorter, '当前remove不支持sorter行为');
|
|
929
923
|
const { aliasDict, filterRefAlias, from: fromText, currentNumber } = this.analyzeJoin(entity, { filter, sorter });
|
|
930
924
|
const alias = aliasDict['./'];
|
|
931
|
-
|
|
925
|
+
// 这里原来includeDeleted传的是true,不知道原因,但不合理
|
|
926
|
+
const { stmt: filterText } = this.translateFilter(entity, filter, aliasDict, filterRefAlias, currentNumber, { includedDeleted: option?.includedDeleted });
|
|
932
927
|
// const sorterText = sorter && sorter.length > 0 ? this.translateSorter(entity, sorter, aliasDict) : undefined;
|
|
933
928
|
const { attributes } = this.schema[entity];
|
|
934
929
|
let updateText = '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-db",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "oak-db",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"author": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"mysql": "^2.18.1",
|
|
20
20
|
"mysql2": "^2.3.3",
|
|
21
|
-
"oak-domain": "^5.1.
|
|
21
|
+
"oak-domain": "^5.1.20",
|
|
22
22
|
"uuid": "^8.3.2"
|
|
23
23
|
},
|
|
24
24
|
"license": "ISC",
|