File tree Expand file tree Collapse file tree 6 files changed +5
-41
lines changed Expand file tree Collapse file tree 6 files changed +5
-41
lines changed Original file line number Diff line number Diff line change @@ -625,7 +625,6 @@ - (id)initWithOrderings:(NSArray<id> *)orderings {
625
625
626
626
@implementation FIRReplaceWithStageBridge {
627
627
FIRExprBridge *_expr;
628
- NSString *_fieldName;
629
628
Boolean isUserDataRead;
630
629
std::shared_ptr<ReplaceWith> cpp_replace_with;
631
630
}
@@ -634,29 +633,14 @@ - (id)initWithExpr:(FIRExprBridge *)expr {
634
633
self = [super init ];
635
634
if (self) {
636
635
_expr = expr;
637
- _fieldName = nil ;
638
- isUserDataRead = NO ;
639
- }
640
- return self;
641
- }
642
-
643
- - (id )initWithFieldName : (NSString *)fieldName {
644
- self = [super init ];
645
- if (self) {
646
- _fieldName = fieldName;
647
- _expr = nil ;
648
636
isUserDataRead = NO ;
649
637
}
650
638
return self;
651
639
}
652
640
653
641
- (std::shared_ptr<api::Stage>)cppStageWithReader : (FSTUserDataReader *)reader {
654
642
if (!isUserDataRead) {
655
- if (_expr) {
656
- cpp_replace_with = std::make_shared<ReplaceWith>([_expr cppExprWithReader: reader]);
657
- } else {
658
- cpp_replace_with = std::make_shared<ReplaceWith>(MakeString (_fieldName));
659
- }
643
+ cpp_replace_with = std::make_shared<ReplaceWith>([_expr cppExprWithReader: reader]);
660
644
}
661
645
662
646
isUserDataRead = YES ;
Original file line number Diff line number Diff line change @@ -173,7 +173,6 @@ NS_SWIFT_SENDABLE
173
173
NS_SWIFT_NAME (ReplaceWithStageBridge)
174
174
@interface FIRReplaceWithStageBridge : FIRStageBridge
175
175
- (id )initWithExpr:(FIRExprBridge *)expr;
176
- - (id )initWithFieldName:(NSString *)fieldName;
177
176
@end
178
177
179
178
NS_SWIFT_SENDABLE
Original file line number Diff line number Diff line change @@ -581,7 +581,7 @@ public struct Pipeline: @unchecked Sendable {
581
581
/// - Parameter fieldName: The name of the field containing the nested map.
582
582
/// - Returns: A new `Pipeline` object with this stage appended.
583
583
public func replace( with fieldName: String ) -> Pipeline {
584
- return Pipeline ( stages: stages + [ ReplaceWith ( fieldName : fieldName) ] , db: db)
584
+ return Pipeline ( stages: stages + [ ReplaceWith ( expr : Field ( fieldName) ) ] , db: db)
585
585
}
586
586
587
587
/// Performs pseudo-random sampling of input documents, returning a specific count.
Original file line number Diff line number Diff line change @@ -256,20 +256,12 @@ class Sort: Stage {
256
256
class ReplaceWith : Stage {
257
257
var name : String = " replaceWith "
258
258
var bridge : StageBridge
259
- private var expr : Expr ?
260
- private var fieldName : String ?
259
+ private var expr : Expr
261
260
262
261
init ( expr: Expr ) {
263
262
self . expr = expr
264
- fieldName = nil
265
263
bridge = ReplaceWithStageBridge ( expr: expr. toBridge ( ) )
266
264
}
267
-
268
- init ( fieldName: String ) {
269
- self . fieldName = fieldName
270
- expr = nil
271
- bridge = ReplaceWithStageBridge ( fieldName: fieldName)
272
- }
273
265
}
274
266
275
267
class Sample : Stage {
Original file line number Diff line number Diff line change @@ -312,24 +312,15 @@ google_firestore_v1_Pipeline_Stage ReplaceWith::to_proto() const {
312
312
313
313
result.args_count = 1 ;
314
314
result.args = nanopb::MakeArray<google_firestore_v1_Value>(1 );
315
- if (expr_) {
316
- result.args [0 ] = expr_->to_proto ();
317
- } else {
318
- result.args [0 ].which_value_type =
319
- google_firestore_v1_Value_string_value_tag;
320
- result.args [0 ].string_value = nanopb::MakeBytesArray (field_name_.value ());
321
- }
315
+ result.args [0 ] = expr_->to_proto ();
322
316
323
317
result.options_count = 0 ;
324
318
result.options = nullptr ;
325
319
return result;
326
320
}
327
321
328
322
ReplaceWith::ReplaceWith (std::shared_ptr<Expr> expr)
329
- : expr_(std::move(expr)), field_name_(absl::nullopt ) {
330
- }
331
- ReplaceWith::ReplaceWith (std::string field_name)
332
- : expr_(nullptr ), field_name_(std::move(field_name)) {
323
+ : expr_(std::move(expr)) {
333
324
}
334
325
335
326
Sample::Sample (std::string type, int64_t count, double percentage)
Original file line number Diff line number Diff line change @@ -253,13 +253,11 @@ class RemoveFieldsStage : public Stage {
253
253
class ReplaceWith : public Stage {
254
254
public:
255
255
explicit ReplaceWith (std::shared_ptr<Expr> expr);
256
- explicit ReplaceWith (std::string field_name);
257
256
~ReplaceWith () override = default ;
258
257
google_firestore_v1_Pipeline_Stage to_proto () const override ;
259
258
260
259
private:
261
260
std::shared_ptr<Expr> expr_;
262
- absl::optional<std::string> field_name_;
263
261
};
264
262
265
263
class Sample : public Stage {
You can’t perform that action at this time.
0 commit comments