Skip to content

Commit 7d6aec1

Browse files
committed
If argument to FunctionExpr is a plain object or array, convert these to expression using map(...) or array(...)
1 parent 16cfd24 commit 7d6aec1

File tree

4 files changed

+163
-166
lines changed

4 files changed

+163
-166
lines changed

packages/firestore/src/core/pipeline-util.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,55 @@ export function toPipelineFilterCondition(f: FilterInternal): FilterCondition {
7676
const value = f.value;
7777
switch (f.op) {
7878
case Operator.LESS_THAN:
79-
return andFunction(field.exists(), field.lt(value));
79+
return andFunction(
80+
field.exists(),
81+
field.lt(Constant._fromProto(value))
82+
);
8083
case Operator.LESS_THAN_OR_EQUAL:
81-
return andFunction(field.exists(), field.lte(value));
84+
return andFunction(
85+
field.exists(),
86+
field.lte(Constant._fromProto(value))
87+
);
8288
case Operator.GREATER_THAN:
83-
return andFunction(field.exists(), field.gt(value));
89+
return andFunction(
90+
field.exists(),
91+
field.gt(Constant._fromProto(value))
92+
);
8493
case Operator.GREATER_THAN_OR_EQUAL:
85-
return andFunction(field.exists(), field.gte(value));
94+
return andFunction(
95+
field.exists(),
96+
field.gte(Constant._fromProto(value))
97+
);
8698
case Operator.EQUAL:
87-
return andFunction(field.exists(), field.eq(value));
99+
return andFunction(
100+
field.exists(),
101+
field.eq(Constant._fromProto(value))
102+
);
88103
case Operator.NOT_EQUAL:
89-
return andFunction(field.exists(), field.neq(value));
104+
return andFunction(
105+
field.exists(),
106+
field.neq(Constant._fromProto(value))
107+
);
90108
case Operator.ARRAY_CONTAINS:
91-
return andFunction(field.exists(), field.arrayContains(value));
109+
return andFunction(
110+
field.exists(),
111+
field.arrayContains(Constant._fromProto(value))
112+
);
92113
case Operator.IN: {
93114
const values = value?.arrayValue?.values?.map((val: any) =>
94-
Constant.of(val)
115+
Constant._fromProto(val)
95116
);
96117
return andFunction(field.exists(), field.eqAny(...values!));
97118
}
98119
case Operator.ARRAY_CONTAINS_ANY: {
99120
const values = value?.arrayValue?.values?.map((val: any) =>
100-
Constant.of(val)
121+
Constant._fromProto(val)
101122
);
102123
return andFunction(field.exists(), field.arrayContainsAny(values!));
103124
}
104125
case Operator.NOT_IN: {
105126
const values = value?.arrayValue?.values?.map((val: any) =>
106-
Constant.of(val)
127+
Constant._fromProto(val)
107128
);
108129
return andFunction(field.exists(), not(field.eqAny(...values!)));
109130
}

0 commit comments

Comments
 (0)