semanticdb-core 1.0.30 → 1.0.32
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.
|
@@ -20,7 +20,19 @@ const isDimensionInQuery = (query, dimension, strictMode = true) => {
|
|
|
20
20
|
const flattenQuery = (0, exports.getFlattenQuery)(query);
|
|
21
21
|
if (strictMode) {
|
|
22
22
|
if (typeof dimension === 'string') {
|
|
23
|
-
|
|
23
|
+
if (!(dimension in flattenQuery)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// 如果是单纯的$exists: true, 不认为是。
|
|
27
|
+
const v = flattenQuery[dimension];
|
|
28
|
+
if (v &&
|
|
29
|
+
typeof v === 'object' &&
|
|
30
|
+
'$exists' in v &&
|
|
31
|
+
v['$exists'] === true &&
|
|
32
|
+
Object.keys(v).length === 1) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
24
36
|
}
|
|
25
37
|
else if (dimension._id in flattenQuery) {
|
|
26
38
|
if ((0, date_1.isStandardDateForm)(flattenQuery[dimension._id])) {
|
|
@@ -31,8 +43,16 @@ const isDimensionInQuery = (query, dimension, strictMode = true) => {
|
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
}
|
|
34
|
-
for (const k of Object.
|
|
46
|
+
for (const [k, v] of Object.entries(flattenQuery)) {
|
|
35
47
|
if (k.startsWith(`${dimension}_`) || k === dimension) {
|
|
48
|
+
// 如果是单纯的$exists: true, 不认为是。
|
|
49
|
+
if (v &&
|
|
50
|
+
typeof v === 'object' &&
|
|
51
|
+
'$exists' in v &&
|
|
52
|
+
v['$exists'] === true &&
|
|
53
|
+
Object.keys(v).length === 1) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
36
56
|
return true;
|
|
37
57
|
}
|
|
38
58
|
}
|
|
@@ -78,14 +98,8 @@ const isDimensionInPred = (predItem, dimension, strictMode = true) => {
|
|
|
78
98
|
return predItem.pred === dimension;
|
|
79
99
|
};
|
|
80
100
|
exports.isDimensionInPred = isDimensionInPred;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* @param logicform
|
|
84
|
-
* @param dimension
|
|
85
|
-
* @param strictMode 是否严格模式,严格模式下,只有完全匹配才返回true,非严格模式下,只要包含就返回true
|
|
86
|
-
* @returns
|
|
87
|
-
*/
|
|
88
|
-
const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
|
|
101
|
+
// 下面isDimensionInLogicform的帮助函数
|
|
102
|
+
const isDimensionInLogicformIgnoreLevel = (logicform, dimension, strictMode = true) => {
|
|
89
103
|
if ((0, exports.isDimensionInQuery)(logicform.query || {}, dimension, strictMode))
|
|
90
104
|
return true;
|
|
91
105
|
if (logicform.groupby && (0, exports.isDimensionInGroupby)(logicform.groupby, dimension)) {
|
|
@@ -103,6 +117,29 @@ const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
|
|
|
103
117
|
}
|
|
104
118
|
return false;
|
|
105
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @param logicform
|
|
123
|
+
* @param dimension
|
|
124
|
+
* @param strictMode 是否严格模式,严格模式下,只有完全匹配才返回true,非严格模式下,只要包含就返回true
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
const isDimensionInLogicform = (logicform, dimension, strictMode = true) => {
|
|
128
|
+
const dimInLFIgnoreLevel = isDimensionInLogicformIgnoreLevel(logicform, dimension, strictMode);
|
|
129
|
+
if (!dimInLFIgnoreLevel)
|
|
130
|
+
return dimInLFIgnoreLevel;
|
|
131
|
+
if (typeof dimension === 'string' || !dimension.level)
|
|
132
|
+
return dimInLFIgnoreLevel;
|
|
133
|
+
if (!logicform.groupby)
|
|
134
|
+
return dimInLFIgnoreLevel;
|
|
135
|
+
// 如果在query和groupby里面都有,那么要拿联合最小粒度。
|
|
136
|
+
if (!logicform.groupby.find((gi) => gi._id === dimension._id))
|
|
137
|
+
return dimInLFIgnoreLevel;
|
|
138
|
+
if (!(0, exports.isDimensionInQuery)(logicform.query || {}, dimension, strictMode))
|
|
139
|
+
return dimInLFIgnoreLevel;
|
|
140
|
+
const dimInGroupby = (0, exports.isDimensionInGroupby)(logicform.groupby, dimension);
|
|
141
|
+
return dimInGroupby;
|
|
142
|
+
};
|
|
106
143
|
exports.isDimensionInLogicform = isDimensionInLogicform;
|
|
107
144
|
/**
|
|
108
145
|
* 将嵌套的查询对象扁平化
|