@finos/legend-query-builder 4.9.4 → 4.10.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/__lib__/QueryBuilderTesting.d.ts +4 -1
- package/lib/__lib__/QueryBuilderTesting.d.ts.map +1 -1
- package/lib/__lib__/QueryBuilderTesting.js +5 -1
- package/lib/__lib__/QueryBuilderTesting.js.map +1 -1
- package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
- package/lib/components/QueryBuilderResultPanel.js +80 -90
- package/lib/components/QueryBuilderResultPanel.js.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +1 -0
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +13 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts +2 -2
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +42 -24
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.d.ts.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderTDSPanel.js.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.d.ts +3 -2
- package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js +145 -8
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/index.css +16 -0
- package/lib/package.json +1 -1
- package/lib/stores/QueryBuilderConstantsState.d.ts +5 -1
- package/lib/stores/QueryBuilderConstantsState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderConstantsState.js +14 -1
- package/lib/stores/QueryBuilderConstantsState.js.map +1 -1
- package/lib/stores/QueryBuilderResultState.d.ts +3 -0
- package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
- package/lib/stores/QueryBuilderResultState.js +31 -2
- package/lib/stores/QueryBuilderResultState.js.map +1 -1
- package/lib/stores/QueryBuilderStateHashUtils.d.ts +2 -0
- package/lib/stores/QueryBuilderStateHashUtils.d.ts.map +1 -1
- package/lib/stores/QueryBuilderStateHashUtils.js +2 -0
- package/lib/stores/QueryBuilderStateHashUtils.js.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js +3 -23
- package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts +31 -5
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js +125 -30
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js +21 -8
- package/lib/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts +3 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +20 -17
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +4 -6
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +4 -6
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +10 -10
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +10 -10
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js +5 -5
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.d.ts +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js +32 -27
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +10 -5
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +10 -10
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js +5 -5
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +4 -6
- package/lib/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.d.ts.map +1 -1
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js +17 -3
- package/lib/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts +7 -1
- package/lib/stores/filter/QueryBuilderFilterState.d.ts.map +1 -1
- package/lib/stores/filter/QueryBuilderFilterState.js +27 -0
- package/lib/stores/filter/QueryBuilderFilterState.js.map +1 -1
- package/package.json +5 -5
- package/src/__lib__/QueryBuilderTesting.ts +5 -1
- package/src/components/QueryBuilderResultPanel.tsx +127 -135
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +25 -1
- package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +102 -49
- package/src/components/fetch-structure/QueryBuilderTDSPanel.tsx +6 -2
- package/src/components/filter/QueryBuilderFilterPanel.tsx +239 -21
- package/src/stores/QueryBuilderConstantsState.ts +30 -0
- package/src/stores/QueryBuilderResultState.ts +36 -1
- package/src/stores/QueryBuilderStateHashUtils.ts +2 -0
- package/src/stores/QueryBuilderValueSpecificationBuilder.ts +4 -50
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterOperator.ts +1 -1
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterState.ts +180 -34
- package/src/stores/fetch-structure/tds/post-filter/QueryBuilderPostFilterStateBuilder.ts +38 -9
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +36 -20
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +5 -6
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +6 -6
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +12 -13
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +10 -9
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.ts +5 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +48 -43
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +12 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +10 -9
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.ts +5 -4
- package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +6 -6
- package/src/stores/fetch-structure/tds/projection/QueryBuilderProjectionColumnState.ts +26 -4
- package/src/stores/filter/QueryBuilderFilterState.ts +40 -1
@@ -27,6 +27,7 @@ import {
|
|
27
27
|
PropertyExplicitReference,
|
28
28
|
Multiplicity,
|
29
29
|
PrimitiveType,
|
30
|
+
type PureModel,
|
30
31
|
} from '@finos/legend-graph';
|
31
32
|
import { guaranteeNonNullable } from '@finos/legend-shared';
|
32
33
|
import type { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
|
@@ -36,27 +37,19 @@ import {
|
|
36
37
|
getTDSColumnDerivedProperyFromType,
|
37
38
|
} from '../QueryBuilderPostFilterState.js';
|
38
39
|
import { QUERY_BUILDER_PURE_PATH } from '../../../../../graph/QueryBuilderMetaModelConst.js';
|
40
|
+
import type { QueryBuilderTDSColumnState } from '../../QueryBuilderTDSColumnState.js';
|
39
41
|
|
40
|
-
export const
|
42
|
+
export const buildtdsPropertyExpressionFromColState = (
|
41
43
|
filterConditionState: PostFilterConditionState,
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
* name. If not provided, we will fall back to use the TDS column getter function expression.
|
47
|
-
* This is the case because with TDS, we are provided some filter-like operators, e.g. IS_NULL, IS_NOT_NULL, etc.
|
48
|
-
*/
|
49
|
-
operatorFunctionFullPath: string | undefined,
|
50
|
-
): FunctionExpression => {
|
51
|
-
// primitives
|
52
|
-
const graph =
|
53
|
-
filterConditionState.postFilterState.tdsState.queryBuilderState
|
54
|
-
.graphManagerState.graph;
|
55
|
-
// property expression
|
56
|
-
const colState = filterConditionState.columnState;
|
44
|
+
colState: QueryBuilderTDSColumnState,
|
45
|
+
graph: PureModel,
|
46
|
+
operator: QueryBuilderPostFilterOperator | undefined,
|
47
|
+
): AbstractPropertyExpression => {
|
57
48
|
const tdsPropertyExpression = new AbstractPropertyExpression('');
|
58
49
|
let tdsDerivedPropertyName: TDS_COLUMN_GETTER;
|
59
|
-
const correspondingTDSDerivedProperty = operator
|
50
|
+
const correspondingTDSDerivedProperty = operator
|
51
|
+
? operator.getTDSColumnGetter()
|
52
|
+
: undefined;
|
60
53
|
if (correspondingTDSDerivedProperty) {
|
61
54
|
tdsDerivedPropertyName = correspondingTDSDerivedProperty;
|
62
55
|
} else {
|
@@ -79,15 +72,38 @@ export const buildPostFilterConditionExpression = (
|
|
79
72
|
);
|
80
73
|
colInstanceValue.values = [colState.columnName];
|
81
74
|
tdsPropertyExpression.parametersValues = [variableName, colInstanceValue];
|
75
|
+
return tdsPropertyExpression;
|
76
|
+
};
|
77
|
+
|
78
|
+
export const buildPostFilterConditionExpression = (
|
79
|
+
filterConditionState: PostFilterConditionState,
|
80
|
+
operator: QueryBuilderPostFilterOperator,
|
81
|
+
/**
|
82
|
+
* If provided, this will be used to construct the simple
|
83
|
+
* function expression for the function with the specified
|
84
|
+
* name. If not provided, we will fall back to use the TDS column getter function expression.
|
85
|
+
* This is the case because with TDS, we are provided some filter-like operators, e.g. IS_NULL, IS_NOT_NULL, etc.
|
86
|
+
*/
|
87
|
+
operatorFunctionFullPath: string | undefined,
|
88
|
+
): FunctionExpression => {
|
89
|
+
// primitives
|
90
|
+
const graph =
|
91
|
+
filterConditionState.postFilterState.tdsState.queryBuilderState
|
92
|
+
.graphManagerState.graph;
|
93
|
+
// property expression
|
94
|
+
const tdsPropertyExpression = buildtdsPropertyExpressionFromColState(
|
95
|
+
filterConditionState,
|
96
|
+
filterConditionState.leftConditionValue,
|
97
|
+
graph,
|
98
|
+
operator,
|
99
|
+
);
|
82
100
|
|
83
101
|
if (operatorFunctionFullPath) {
|
84
102
|
const expression = new SimpleFunctionExpression(
|
85
103
|
extractElementNameFromPath(operatorFunctionFullPath),
|
86
104
|
);
|
87
105
|
expression.parametersValues.push(tdsPropertyExpression);
|
88
|
-
|
89
|
-
expression.parametersValues.push(filterConditionState.value);
|
90
|
-
}
|
106
|
+
filterConditionState.rightConditionValue.appendConditionValue(expression);
|
91
107
|
return expression;
|
92
108
|
} else {
|
93
109
|
return tdsPropertyExpression;
|
@@ -37,7 +37,6 @@ import type {
|
|
37
37
|
import {
|
38
38
|
buildNotExpression,
|
39
39
|
generateDefaultValueForPrimitiveType,
|
40
|
-
getNonCollectionValueSpecificationType,
|
41
40
|
unwrapNotExpression,
|
42
41
|
} from '../../../../QueryBuilderValueSpecificationHelper.js';
|
43
42
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
@@ -60,17 +59,17 @@ export class QueryBuilderPostFilterOperator_Contain
|
|
60
59
|
isCompatibleWithConditionValue(
|
61
60
|
postFilterConditionState: PostFilterConditionState,
|
62
61
|
): boolean {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
return (
|
63
|
+
!postFilterConditionState.rightConditionValue.isCollection &&
|
64
|
+
PrimitiveType.STRING === postFilterConditionState.rightConditionValue.type
|
65
|
+
);
|
67
66
|
}
|
68
67
|
|
69
68
|
getDefaultFilterConditionValue(
|
70
69
|
postFilterConditionState: PostFilterConditionState,
|
71
70
|
): ValueSpecification {
|
72
71
|
const propertyType = guaranteeNonNullable(
|
73
|
-
postFilterConditionState.
|
72
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
74
73
|
);
|
75
74
|
switch (propertyType.path) {
|
76
75
|
case PRIMITIVE_TYPE.STRING: {
|
@@ -35,7 +35,6 @@ import type {
|
|
35
35
|
import {
|
36
36
|
buildNotExpression,
|
37
37
|
generateDefaultValueForPrimitiveType,
|
38
|
-
getNonCollectionValueSpecificationType,
|
39
38
|
unwrapNotExpression,
|
40
39
|
} from '../../../../QueryBuilderValueSpecificationHelper.js';
|
41
40
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
@@ -58,16 +57,17 @@ export class QueryBuilderPostFilterOperator_EndWith
|
|
58
57
|
isCompatibleWithConditionValue(
|
59
58
|
postFilterConditionState: PostFilterConditionState,
|
60
59
|
): boolean {
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
return (
|
61
|
+
!postFilterConditionState.rightConditionValue.isCollection &&
|
62
|
+
PrimitiveType.STRING === postFilterConditionState.rightConditionValue.type
|
63
|
+
);
|
65
64
|
}
|
66
65
|
|
67
66
|
getDefaultFilterConditionValue(
|
68
67
|
postFilterConditionState: PostFilterConditionState,
|
69
68
|
): ValueSpecification {
|
70
|
-
const propertyType =
|
69
|
+
const propertyType =
|
70
|
+
postFilterConditionState.leftConditionValue.getColumnType();
|
71
71
|
switch (propertyType?.path) {
|
72
72
|
case PRIMITIVE_TYPE.STRING: {
|
73
73
|
return buildPrimitiveInstanceValue(
|
package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts
CHANGED
@@ -27,6 +27,7 @@ import {
|
|
27
27
|
GenericType,
|
28
28
|
GenericTypeExplicitReference,
|
29
29
|
PRIMITIVE_TYPE,
|
30
|
+
PrimitiveType,
|
30
31
|
} from '@finos/legend-graph';
|
31
32
|
import {
|
32
33
|
guaranteeNonNullable,
|
@@ -36,14 +37,13 @@ import {
|
|
36
37
|
} from '@finos/legend-shared';
|
37
38
|
import { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
|
38
39
|
import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
|
39
|
-
import
|
40
|
-
PostFilterConditionState,
|
41
|
-
QueryBuilderPostFilterState,
|
40
|
+
import {
|
41
|
+
type PostFilterConditionState,
|
42
|
+
type QueryBuilderPostFilterState,
|
42
43
|
} from '../QueryBuilderPostFilterState.js';
|
43
44
|
import {
|
44
45
|
buildNotExpression,
|
45
46
|
generateDefaultValueForPrimitiveType,
|
46
|
-
getNonCollectionValueSpecificationType,
|
47
47
|
isTypeCompatibleForAssignment,
|
48
48
|
unwrapNotExpression,
|
49
49
|
} from '../../../../QueryBuilderValueSpecificationHelper.js';
|
@@ -84,12 +84,11 @@ export class QueryBuilderPostFilterOperator_Equal
|
|
84
84
|
isCompatibleWithConditionValue(
|
85
85
|
postFilterConditionState: PostFilterConditionState,
|
86
86
|
): boolean {
|
87
|
-
|
88
|
-
if (valueSpecification) {
|
87
|
+
if (!postFilterConditionState.rightConditionValue.isCollection) {
|
89
88
|
return isTypeCompatibleForAssignment(
|
90
|
-
|
89
|
+
postFilterConditionState.rightConditionValue.type,
|
91
90
|
guaranteeNonNullable(
|
92
|
-
postFilterConditionState.
|
91
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
93
92
|
),
|
94
93
|
);
|
95
94
|
}
|
@@ -100,7 +99,7 @@ export class QueryBuilderPostFilterOperator_Equal
|
|
100
99
|
postFilterConditionState: PostFilterConditionState,
|
101
100
|
): ValueSpecification {
|
102
101
|
const propertyType = guaranteeNonNullable(
|
103
|
-
postFilterConditionState.
|
102
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
104
103
|
);
|
105
104
|
switch (propertyType.path) {
|
106
105
|
case PRIMITIVE_TYPE.STRING:
|
@@ -170,10 +169,10 @@ export class QueryBuilderPostFilterOperator_Equal
|
|
170
169
|
return buildPostFilterConditionExpression(
|
171
170
|
postFilterConditionState,
|
172
171
|
this,
|
173
|
-
postFilterConditionState.
|
174
|
-
|
175
|
-
postFilterConditionState.
|
176
|
-
|
172
|
+
postFilterConditionState.leftConditionValue.getColumnType() ===
|
173
|
+
PrimitiveType.DATETIME &&
|
174
|
+
postFilterConditionState.rightConditionValue.type !==
|
175
|
+
PrimitiveType.DATETIME
|
177
176
|
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_ON_DAY
|
178
177
|
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.EQUAL,
|
179
178
|
);
|
@@ -20,6 +20,7 @@ import {
|
|
20
20
|
type FunctionExpression,
|
21
21
|
AbstractPropertyExpression,
|
22
22
|
PRIMITIVE_TYPE,
|
23
|
+
PrimitiveType,
|
23
24
|
} from '@finos/legend-graph';
|
24
25
|
import {
|
25
26
|
guaranteeNonNullable,
|
@@ -35,7 +36,6 @@ import type {
|
|
35
36
|
} from '../QueryBuilderPostFilterState.js';
|
36
37
|
import {
|
37
38
|
generateDefaultValueForPrimitiveType,
|
38
|
-
getNonCollectionValueSpecificationType,
|
39
39
|
isTypeCompatibleForAssignment,
|
40
40
|
} from '../../../../QueryBuilderValueSpecificationHelper.js';
|
41
41
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
@@ -69,11 +69,11 @@ export class QueryBuilderPostFilterOperator_GreaterThan
|
|
69
69
|
postFilterConditionState: PostFilterConditionState,
|
70
70
|
): boolean {
|
71
71
|
return isTypeCompatibleForAssignment(
|
72
|
-
postFilterConditionState.
|
73
|
-
?
|
72
|
+
!postFilterConditionState.rightConditionValue.isCollection
|
73
|
+
? postFilterConditionState.rightConditionValue.type
|
74
74
|
: undefined,
|
75
75
|
guaranteeNonNullable(
|
76
|
-
postFilterConditionState.
|
76
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
77
77
|
),
|
78
78
|
);
|
79
79
|
}
|
@@ -81,7 +81,8 @@ export class QueryBuilderPostFilterOperator_GreaterThan
|
|
81
81
|
getDefaultFilterConditionValue(
|
82
82
|
postFilterConditionState: PostFilterConditionState,
|
83
83
|
): ValueSpecification {
|
84
|
-
const propertyType =
|
84
|
+
const propertyType =
|
85
|
+
postFilterConditionState.leftConditionValue.getColumnType();
|
85
86
|
switch (propertyType?.path) {
|
86
87
|
case PRIMITIVE_TYPE.NUMBER:
|
87
88
|
case PRIMITIVE_TYPE.DECIMAL:
|
@@ -121,10 +122,10 @@ export class QueryBuilderPostFilterOperator_GreaterThan
|
|
121
122
|
return buildPostFilterConditionExpression(
|
122
123
|
postFilterConditionState,
|
123
124
|
this,
|
124
|
-
postFilterConditionState.
|
125
|
-
|
126
|
-
postFilterConditionState.
|
127
|
-
|
125
|
+
postFilterConditionState.leftConditionValue.getColumnType() ===
|
126
|
+
PrimitiveType.DATETIME &&
|
127
|
+
postFilterConditionState.rightConditionValue.type !==
|
128
|
+
PrimitiveType.DATETIME
|
128
129
|
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_AFTER_DAY
|
129
130
|
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN,
|
130
131
|
);
|
@@ -19,6 +19,7 @@ import {
|
|
19
19
|
type ValueSpecification,
|
20
20
|
AbstractPropertyExpression,
|
21
21
|
PRIMITIVE_TYPE,
|
22
|
+
PrimitiveType,
|
22
23
|
} from '@finos/legend-graph';
|
23
24
|
import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
|
24
25
|
import type {
|
@@ -42,10 +43,10 @@ export class QueryBuilderPostFilterOperator_GreaterThanEqual extends QueryBuilde
|
|
42
43
|
return buildPostFilterConditionExpression(
|
43
44
|
postFilterConditionState,
|
44
45
|
this,
|
45
|
-
postFilterConditionState.
|
46
|
-
|
47
|
-
postFilterConditionState.
|
48
|
-
|
46
|
+
postFilterConditionState.leftConditionValue.getColumnType() ===
|
47
|
+
PrimitiveType.DATETIME &&
|
48
|
+
postFilterConditionState.rightConditionValue.type !==
|
49
|
+
PrimitiveType.DATETIME
|
49
50
|
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_ON_OR_AFTER_DAY
|
50
51
|
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.GREATER_THAN_EQUAL,
|
51
52
|
);
|
package/src/stores/fetch-structure/tds/post-filter/operators/QueryBuilderPostFilterOperator_In.ts
CHANGED
@@ -34,9 +34,10 @@ import {
|
|
34
34
|
} from '@finos/legend-shared';
|
35
35
|
import { QueryBuilderPostFilterOperator } from '../QueryBuilderPostFilterOperator.js';
|
36
36
|
import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
|
37
|
-
import
|
38
|
-
|
39
|
-
|
37
|
+
import {
|
38
|
+
PostFilterValueSpecConditionValueState,
|
39
|
+
type PostFilterConditionState,
|
40
|
+
type QueryBuilderPostFilterState,
|
40
41
|
} from '../QueryBuilderPostFilterState.js';
|
41
42
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
42
43
|
import {
|
@@ -75,47 +76,51 @@ export class QueryBuilderPostFilterOperator_In
|
|
75
76
|
postFilterConditionState: PostFilterConditionState,
|
76
77
|
): boolean {
|
77
78
|
const propertyType = guaranteeNonNullable(
|
78
|
-
postFilterConditionState.
|
79
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
79
80
|
);
|
80
|
-
const
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
81
|
+
const rightSide = postFilterConditionState.rightConditionValue;
|
82
|
+
// `in`/`not in` doest not support right hand value being column state as the multipliticy for columns are [0..1]
|
83
|
+
if (rightSide instanceof PostFilterValueSpecConditionValueState) {
|
84
|
+
const valueSpec = rightSide.value;
|
85
|
+
if (valueSpec instanceof CollectionInstanceValue) {
|
86
|
+
if (valueSpec.values.length === 0) {
|
87
|
+
return true;
|
88
|
+
}
|
89
|
+
const collectionType = getCollectionValueSpecificationType(
|
90
|
+
postFilterConditionState.postFilterState.tdsState.queryBuilderState
|
91
|
+
.graphManagerState.graph,
|
92
|
+
valueSpec.values,
|
93
|
+
);
|
94
|
+
if (!collectionType) {
|
95
|
+
return false;
|
96
|
+
}
|
97
|
+
if (
|
98
|
+
(
|
99
|
+
[
|
100
|
+
PRIMITIVE_TYPE.NUMBER,
|
101
|
+
PRIMITIVE_TYPE.INTEGER,
|
102
|
+
PRIMITIVE_TYPE.DECIMAL,
|
103
|
+
PRIMITIVE_TYPE.FLOAT,
|
104
|
+
] as string[]
|
105
|
+
).includes(propertyType.path)
|
106
|
+
) {
|
107
|
+
return (
|
108
|
+
[
|
109
|
+
PRIMITIVE_TYPE.NUMBER,
|
110
|
+
PRIMITIVE_TYPE.INTEGER,
|
111
|
+
PRIMITIVE_TYPE.DECIMAL,
|
112
|
+
PRIMITIVE_TYPE.FLOAT,
|
113
|
+
] as string[]
|
114
|
+
).includes(collectionType.path);
|
115
|
+
}
|
116
|
+
return collectionType === propertyType;
|
117
|
+
} else if (valueSpec instanceof VariableExpression) {
|
118
|
+
// check if not a single value
|
119
|
+
if (valueSpec.multiplicity.upperBound === 1) {
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
return propertyType === valueSpec.genericType?.value.rawType;
|
117
123
|
}
|
118
|
-
return propertyType === valueSpec.genericType?.value.rawType;
|
119
124
|
}
|
120
125
|
return false;
|
121
126
|
}
|
@@ -124,7 +129,7 @@ export class QueryBuilderPostFilterOperator_In
|
|
124
129
|
postFilterConditionState: PostFilterConditionState,
|
125
130
|
): ValueSpecification {
|
126
131
|
const propertyType = guaranteeNonNullable(
|
127
|
-
postFilterConditionState.
|
132
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
128
133
|
);
|
129
134
|
return new CollectionInstanceValue(
|
130
135
|
Multiplicity.ONE,
|
@@ -27,6 +27,7 @@ import {
|
|
27
27
|
type PostFilterConditionState,
|
28
28
|
type QueryBuilderPostFilterState,
|
29
29
|
TDS_COLUMN_GETTER,
|
30
|
+
PostFilterValueSpecConditionValueState,
|
30
31
|
} from '../QueryBuilderPostFilterState.js';
|
31
32
|
import { QueryBuilderSimpleProjectionColumnState } from '../../projection/QueryBuilderProjectionColumnState.js';
|
32
33
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
@@ -53,20 +54,27 @@ export class QueryBuilderPostFilterOperator_IsEmpty
|
|
53
54
|
isCompatibleWithConditionValue(
|
54
55
|
postFilterConditionState: PostFilterConditionState,
|
55
56
|
): boolean {
|
56
|
-
|
57
|
+
if (
|
58
|
+
postFilterConditionState.rightConditionValue instanceof
|
59
|
+
PostFilterValueSpecConditionValueState &&
|
60
|
+
postFilterConditionState.rightConditionValue.value === undefined
|
61
|
+
) {
|
62
|
+
return true;
|
63
|
+
}
|
64
|
+
return false;
|
57
65
|
}
|
58
66
|
|
59
67
|
override isCompatibleWithPostFilterColumn(
|
60
68
|
postFilterState: PostFilterConditionState,
|
61
69
|
): boolean {
|
62
|
-
const columnType = postFilterState.
|
70
|
+
const columnType = postFilterState.leftConditionValue.getColumnType();
|
63
71
|
if (columnType && this.isCompatibleWithType(columnType)) {
|
64
72
|
if (
|
65
|
-
postFilterState.
|
73
|
+
postFilterState.leftConditionValue instanceof
|
66
74
|
QueryBuilderSimpleProjectionColumnState
|
67
75
|
) {
|
68
76
|
return isPropertyExpressionChainOptional(
|
69
|
-
postFilterState.
|
77
|
+
postFilterState.leftConditionValue.propertyExpressionState
|
70
78
|
.propertyExpression,
|
71
79
|
);
|
72
80
|
}
|
@@ -20,6 +20,7 @@ import {
|
|
20
20
|
AbstractPropertyExpression,
|
21
21
|
type FunctionExpression,
|
22
22
|
PRIMITIVE_TYPE,
|
23
|
+
PrimitiveType,
|
23
24
|
} from '@finos/legend-graph';
|
24
25
|
import {
|
25
26
|
guaranteeNonNullable,
|
@@ -35,7 +36,6 @@ import type {
|
|
35
36
|
} from '../QueryBuilderPostFilterState.js';
|
36
37
|
import {
|
37
38
|
generateDefaultValueForPrimitiveType,
|
38
|
-
getNonCollectionValueSpecificationType,
|
39
39
|
isTypeCompatibleForAssignment,
|
40
40
|
} from '../../../../QueryBuilderValueSpecificationHelper.js';
|
41
41
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
@@ -69,11 +69,11 @@ export class QueryBuilderPostFilterOperator_LessThan
|
|
69
69
|
postFilterConditionState: PostFilterConditionState,
|
70
70
|
): boolean {
|
71
71
|
return isTypeCompatibleForAssignment(
|
72
|
-
postFilterConditionState.
|
73
|
-
?
|
72
|
+
!postFilterConditionState.rightConditionValue.isCollection
|
73
|
+
? postFilterConditionState.rightConditionValue.type
|
74
74
|
: undefined,
|
75
75
|
guaranteeNonNullable(
|
76
|
-
postFilterConditionState.
|
76
|
+
postFilterConditionState.leftConditionValue.getColumnType(),
|
77
77
|
),
|
78
78
|
);
|
79
79
|
}
|
@@ -81,7 +81,8 @@ export class QueryBuilderPostFilterOperator_LessThan
|
|
81
81
|
getDefaultFilterConditionValue(
|
82
82
|
postFilterConditionState: PostFilterConditionState,
|
83
83
|
): ValueSpecification {
|
84
|
-
const propertyType =
|
84
|
+
const propertyType =
|
85
|
+
postFilterConditionState.leftConditionValue.getColumnType();
|
85
86
|
switch (propertyType?.path) {
|
86
87
|
case PRIMITIVE_TYPE.NUMBER:
|
87
88
|
case PRIMITIVE_TYPE.DECIMAL:
|
@@ -121,10 +122,10 @@ export class QueryBuilderPostFilterOperator_LessThan
|
|
121
122
|
return buildPostFilterConditionExpression(
|
122
123
|
postFilterConditionState,
|
123
124
|
this,
|
124
|
-
postFilterConditionState.
|
125
|
-
|
126
|
-
postFilterConditionState.
|
127
|
-
|
125
|
+
postFilterConditionState.leftConditionValue.getColumnType() ===
|
126
|
+
PrimitiveType.DATETIME &&
|
127
|
+
postFilterConditionState.rightConditionValue.type !==
|
128
|
+
PrimitiveType.DATETIME
|
128
129
|
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_BEFORE_DAY
|
129
130
|
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.LESS_THAN,
|
130
131
|
);
|
@@ -19,6 +19,7 @@ import {
|
|
19
19
|
type ValueSpecification,
|
20
20
|
AbstractPropertyExpression,
|
21
21
|
PRIMITIVE_TYPE,
|
22
|
+
PrimitiveType,
|
22
23
|
} from '@finos/legend-graph';
|
23
24
|
import { buildPostFilterConditionState } from '../QueryBuilderPostFilterStateBuilder.js';
|
24
25
|
import type {
|
@@ -45,10 +46,10 @@ export class QueryBuilderPostFilterOperator_LessThanEqual
|
|
45
46
|
return buildPostFilterConditionExpression(
|
46
47
|
postFilterConditionState,
|
47
48
|
this,
|
48
|
-
postFilterConditionState.
|
49
|
-
|
50
|
-
postFilterConditionState.
|
51
|
-
|
49
|
+
postFilterConditionState.leftConditionValue.getColumnType() ===
|
50
|
+
PrimitiveType.DATETIME &&
|
51
|
+
postFilterConditionState.rightConditionValue.type !==
|
52
|
+
PrimitiveType.DATETIME
|
52
53
|
? QUERY_BUILDER_SUPPORTED_FUNCTIONS.IS_ON_OR_BEFORE_DAY
|
53
54
|
: QUERY_BUILDER_SUPPORTED_FUNCTIONS.LESS_THAN_EQUAL,
|
54
55
|
);
|
@@ -36,7 +36,6 @@ import type {
|
|
36
36
|
import {
|
37
37
|
buildNotExpression,
|
38
38
|
generateDefaultValueForPrimitiveType,
|
39
|
-
getNonCollectionValueSpecificationType,
|
40
39
|
unwrapNotExpression,
|
41
40
|
} from '../../../../QueryBuilderValueSpecificationHelper.js';
|
42
41
|
import { buildPostFilterConditionExpression } from './QueryBuilderPostFilterOperatorValueSpecificationBuilder.js';
|
@@ -59,16 +58,17 @@ export class QueryBuilderPostFilterOperator_StartWith
|
|
59
58
|
isCompatibleWithConditionValue(
|
60
59
|
postFilterConditionState: PostFilterConditionState,
|
61
60
|
): boolean {
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
return (
|
62
|
+
!postFilterConditionState.rightConditionValue.isCollection &&
|
63
|
+
PrimitiveType.STRING === postFilterConditionState.rightConditionValue.type
|
64
|
+
);
|
66
65
|
}
|
67
66
|
|
68
67
|
getDefaultFilterConditionValue(
|
69
68
|
postFilterConditionState: PostFilterConditionState,
|
70
69
|
): ValueSpecification {
|
71
|
-
const propertyType =
|
70
|
+
const propertyType =
|
71
|
+
postFilterConditionState.leftConditionValue.getColumnType();
|
72
72
|
switch (propertyType?.path) {
|
73
73
|
case PRIMITIVE_TYPE.STRING: {
|
74
74
|
return buildPrimitiveInstanceValue(
|
@@ -372,20 +372,42 @@ export class QueryBuilderDerivationProjectionColumnState
|
|
372
372
|
const variable = projectionParameter[0] as VariableExpression;
|
373
373
|
assertNonEmptyString(variable.name);
|
374
374
|
// assign variable to query class
|
375
|
+
const queryBuilderState = this.tdsState.queryBuilderState;
|
375
376
|
const rawVariableExpression = new RawVariableExpression(
|
376
377
|
variable.name,
|
377
378
|
Multiplicity.ONE,
|
378
379
|
PackageableElementExplicitReference.create(
|
379
|
-
guaranteeNonNullable(
|
380
|
+
guaranteeNonNullable(queryBuilderState.class),
|
380
381
|
),
|
381
382
|
);
|
382
383
|
const _rawVariableExpression =
|
383
|
-
|
384
|
+
queryBuilderState.graphManagerState.graphManager.serializeRawValueSpecification(
|
384
385
|
rawVariableExpression,
|
385
386
|
);
|
387
|
+
const parameters = queryBuilderState.parametersState.parameterStates.map(
|
388
|
+
(_param) =>
|
389
|
+
queryBuilderState.graphManagerState.graphManager.serializeValueSpecification(
|
390
|
+
_param.parameter,
|
391
|
+
),
|
392
|
+
);
|
393
|
+
const letExpressions = queryBuilderState.constantState.constants
|
394
|
+
.map((_const) => _const.buildLetExpression())
|
395
|
+
.map((expres) =>
|
396
|
+
queryBuilderState.graphManagerState.graphManager.serializeValueSpecification(
|
397
|
+
expres,
|
398
|
+
),
|
399
|
+
);
|
400
|
+
let lambdaBody = this.lambda.body;
|
401
|
+
if (letExpressions.length) {
|
402
|
+
if (Array.isArray(this.lambda.body)) {
|
403
|
+
lambdaBody = [...letExpressions, ...(this.lambda.body as object[])];
|
404
|
+
} else {
|
405
|
+
lambdaBody = [...letExpressions, this.lambda.body];
|
406
|
+
}
|
407
|
+
}
|
386
408
|
const isolatedLambda = new RawLambda(
|
387
|
-
[_rawVariableExpression],
|
388
|
-
|
409
|
+
[_rawVariableExpression, ...parameters],
|
410
|
+
lambdaBody,
|
389
411
|
);
|
390
412
|
return isolatedLambda;
|
391
413
|
}
|