Skip to content

Commit afab672

Browse files
committed
refactor(firestore): remove variable expression handling from multiple platforms
1 parent 6c0e63b commit afab672

5 files changed

Lines changed: 16 additions & 42 deletions

File tree

packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/utils/ExpressionParsers.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ Expression parseExpression(@NonNull Map<String, Object> expressionMap) {
136136
}
137137
return Expression.field(fieldName);
138138
}
139-
case "variable":
140-
{
141-
String variableName = (String) args.get("name");
142-
if (variableName == null) {
143-
throw new IllegalArgumentException("Variable expression must have a 'name' argument");
144-
}
145-
return Expression.variable(variableName);
146-
}
147139
case "constant":
148140
{
149141
Object value = args.get("value");

packages/cloud_firestore/cloud_firestore/ios/cloud_firestore/Sources/cloud_firestore/FLTPipelineParser.m

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,6 @@ - (FIRExprBridge *)parseExpression:(NSDictionary<NSString *, id> *)map error:(NS
116116
return [[FIRFieldBridge alloc] initWithName:field];
117117
}
118118

119-
if ([name isEqualToString:@"variable"]) {
120-
NSString *variableName = args[@"name"];
121-
if (![variableName isKindOfClass:[NSString class]] || variableName.length == 0) {
122-
if (error) *error = parseError(@"Variable expression requires 'name' argument");
123-
return nil;
124-
}
125-
return FLTNewFunctionExprBridge(@"variable",
126-
@[ [[FIRConstantBridge alloc] init:variableName] ]);
127-
}
128-
129119
if ([name isEqualToString:@"constant"]) {
130120
id value = args[@"value"];
131121
if (value == nil) {

packages/cloud_firestore/cloud_firestore/pipeline_example/integration_test/pipeline/pipeline_expressions_e2e.dart

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -820,28 +820,23 @@ void runPipelineExpressionsTests() {
820820
expect(snapshot.result[0].data()!['tags_rev'], ['q', 'p']);
821821
});
822822

823-
test(
824-
'addFields with arraySlice returns sliced array',
825-
() async {
826-
final snapshot = await firestore
827-
.pipeline()
828-
.collection('pipeline-e2e')
829-
.where(Expression.field('test').equalValue('expressions'))
830-
.where(Expression.field('score').equalValue(50))
831-
.addFields(
832-
Expression.field('arr').arraySlice(1, 2).as('arr_slice'),
833-
)
834-
.limit(1)
835-
.execute();
823+
test('addFields with arraySlice returns sliced array', () async {
824+
final snapshot = await firestore
825+
.pipeline()
826+
.collection('pipeline-e2e')
827+
.where(Expression.field('test').equalValue('expressions'))
828+
.where(Expression.field('score').equalValue(50))
829+
.addFields(Expression.field('arr').arraySlice(1, 2).as('arr_slice'))
830+
.limit(1)
831+
.execute();
836832

837-
expectResultCount(snapshot, 1);
838-
expectResultsData(snapshot, [
839-
{
840-
'arr_slice': [4, 6],
841-
},
842-
]);
843-
},
844-
);
833+
expectResultCount(snapshot, 1);
834+
expectResultsData(snapshot, [
835+
{
836+
'arr_slice': [4, 6],
837+
},
838+
]);
839+
});
845840

846841
test(
847842
'arraySum addFields succeeds on Android',

packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ extension type PipelinesJsImpl._(JSObject _) implements JSObject {
353353

354354
// --- Expression builders ---
355355
external ExpressionJsImpl field(JSString path);
356-
external ExpressionJsImpl variable(JSString name);
357356
external ExpressionJsImpl constant(JSAny? value);
358357

359358
// --- Boolean / comparison ---

packages/cloud_firestore/cloud_firestore_web/lib/src/pipeline_expression_parser_web.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class PipelineExpressionParserWeb {
4040
switch (name) {
4141
case 'field':
4242
return _pipelines.field(((argsMap[_kField] as String?) ?? '').toJS);
43-
case 'variable':
44-
return _pipelines.variable(((argsMap[_kName] as String?) ?? '').toJS);
4543
case 'add':
4644
return _binaryArithmetic(argsMap, (l, r) => l.add(r));
4745
case 'subtract':

0 commit comments

Comments
 (0)