Skip to content

Commit 086ccac

Browse files
committed
Merge branch 'firestore-pipelines-dart-api-v2' into firestore-pipelines-android
2 parents f9e6ab0 + f0c217e commit 086ccac

File tree

3 files changed

+29
-42
lines changed

3 files changed

+29
-42
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -605,20 +605,6 @@ void runPipelineExpressionsTests() {
605605
expect(snapshot.result[0].data()!['arr_concat_multi'], [2, 4, 6, 10, 11]);
606606
});
607607

608-
test(
609-
'addFields arraySlice',
610-
() async {
611-
final snapshot = await expressionsDocScore50(
612-
Expression.field('arr').arraySliceLiteral(1, 3).as('arr_slice'),
613-
);
614-
expectResultCount(snapshot, 1);
615-
expect(snapshot.result[0].data()!['arr_slice'], [4, 6]);
616-
},
617-
skip:
618-
defaultTargetPlatform == TargetPlatform.android ||
619-
defaultTargetPlatform == TargetPlatform.iOS,
620-
);
621-
622608
test('addFields arrayContainsAny', () async {
623609
final snapshot = await expressionsDocScore50(
624610
Expression.field('arr').arrayContainsAny([2, 99]).as('arr_has_any'),

packages/cloud_firestore/cloud_firestore/pipeline_example/lib/main.dart

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -869,20 +869,6 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
869869
.execute(),
870870
);
871871

872-
// 39: array_slice
873-
Future<void> _runPipeline39() => _runPipeline(
874-
'Pipeline 39: where(has tags) → addFields arraySlice(tags, 0, 2)',
875-
() => _firestore
876-
.pipeline()
877-
.collection(_collectionId)
878-
.where(Expression.field('tags').exists())
879-
.addFields(
880-
Expression.field('tags').arraySliceLiteral(0, 2).as('tags_slice'),
881-
)
882-
.limit(3)
883-
.execute(),
884-
);
885-
886872
// 40: array (construct)
887873
Future<void> _runPipeline40() => _runPipeline(
888874
'Pipeline 40: addFields array([title, score, year])',
@@ -952,6 +938,33 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
952938
.execute(),
953939
);
954940

941+
// 45: asBoolean (coerce numeric to boolean)
942+
Future<void> _runPipeline45() => _runPipeline(
943+
'Pipeline 45: addFields asBoolean(score)',
944+
() => _firestore
945+
.pipeline()
946+
.collection(_collectionId)
947+
.addFields(Expression.field('score').asBoolean().as('score_bool'))
948+
.limit(4)
949+
.execute(),
950+
);
951+
952+
// 46: isError (missing field vs divide-by-zero)
953+
Future<void> _runPipeline46() => _runPipeline(
954+
'Pipeline 46: addFields isError(missing field), isError(score/0)',
955+
() => _firestore
956+
.pipeline()
957+
.collection(_collectionId)
958+
.addFields(
959+
Expression.field('missing_field').isError().as('missing_is_err'),
960+
Expression.field(
961+
'score',
962+
).divide(Expression.constant(0)).isError().as('div0_is_err'),
963+
)
964+
.limit(3)
965+
.execute(),
966+
);
967+
955968
@override
956969
Widget build(BuildContext context) {
957970
return Scaffold(
@@ -1044,12 +1057,13 @@ class _PipelineExamplePageState extends State<PipelineExamplePage> {
10441057
_btn('37: arrayLen', _runPipeline37),
10451058
_btn('37b: arraySum', _runPipeline37b),
10461059
_btn('38: arrayConcat', _runPipeline38),
1047-
_btn('39: arraySlice', _runPipeline39),
10481060
_btn('40: array()', _runPipeline40),
10491061
_btn('41: map()', _runPipeline41),
10501062
_btn('42: arrayContainsAll', _runPipeline42),
10511063
_btn('43: equalAny', _runPipeline43),
10521064
_btn('44: notEqualAny', _runPipeline44),
1065+
_btn('45: asBoolean', _runPipeline45),
1066+
_btn('46: isError', _runPipeline46),
10531067
],
10541068
),
10551069
),

packages/cloud_firestore/cloud_firestore/test/pipeline_expression_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -649,19 +649,6 @@ void main() {
649649
});
650650
});
651651

652-
test('arraySlice serializes correctly', () {
653-
final arr = Expression.array([Constant(1), Constant(2), Constant(3)]);
654-
final expr = arr.arraySlice(Constant(0), Constant(2));
655-
expect(expr.toMap(), {
656-
'name': 'array_slice',
657-
'args': {
658-
'array': arr.toMap(),
659-
'start': Constant(0).toMap(),
660-
'end': Constant(2).toMap(),
661-
},
662-
});
663-
});
664-
665652
test('arraySum serializes correctly', () {
666653
final expr = Field('values').arraySum();
667654
expect(expr.toMap()['name'], 'array_sum');

0 commit comments

Comments
 (0)