aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Remote
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-05 11:30:59 -0500
committerGravatar GitHub <noreply@github.com>2018-03-05 11:30:59 -0500
commit1c40e7aada6b32bbc621f06fb5f380149606a58d (patch)
tree6dee81f74f8a33d1beae915d9227caf28b8e2598 /Firestore/Source/Remote
parent9b5b4d876eb77e65b3246614855088be101eebf3 (diff)
add converters and port paths to FSTQuery (#869)
* add converters and fix FSTQuery.{h,m} only * address changes * a change forget to address * add a dummy function to make inline-only-library buildable
Diffstat (limited to 'Firestore/Source/Remote')
-rw-r--r--Firestore/Source/Remote/FSTRemoteStore.mm4
-rw-r--r--Firestore/Source/Remote/FSTSerializerBeta.mm31
2 files changed, 21 insertions, 14 deletions
diff --git a/Firestore/Source/Remote/FSTRemoteStore.mm b/Firestore/Source/Remote/FSTRemoteStore.mm
index b2e4013..b762722 100644
--- a/Firestore/Source/Remote/FSTRemoteStore.mm
+++ b/Firestore/Source/Remote/FSTRemoteStore.mm
@@ -27,6 +27,7 @@
#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTMutation.h"
#import "Firestore/Source/Model/FSTMutationBatch.h"
+#import "Firestore/Source/Model/FSTPath.h"
#import "Firestore/Source/Remote/FSTDatastore.h"
#import "Firestore/Source/Remote/FSTExistenceFilter.h"
#import "Firestore/Source/Remote/FSTRemoteEvent.h"
@@ -446,7 +447,8 @@ static const int kOnlineAttemptsBeforeFailure = 2;
// updates. Without applying a deleted document there might be another query that will
// raise this document as part of a snapshot until it is resolved, essentially exposing
// inconsistency between queries
- FSTDocumentKey *key = [FSTDocumentKey keyWithPath:query.path];
+ FSTDocumentKey *key = [FSTDocumentKey
+ keyWithPath:[FSTResourcePath resourcePathWithCPPResourcePath:query.path]];
FSTDeletedDocument *deletedDoc =
[FSTDeletedDocument documentWithKey:key version:snapshotVersion];
[remoteEvent addDocumentUpdate:deletedDoc];
diff --git a/Firestore/Source/Remote/FSTSerializerBeta.mm b/Firestore/Source/Remote/FSTSerializerBeta.mm
index ceb0501..1dc7c79 100644
--- a/Firestore/Source/Remote/FSTSerializerBeta.mm
+++ b/Firestore/Source/Remote/FSTSerializerBeta.mm
@@ -654,7 +654,8 @@ NS_ASSUME_NONNULL_BEGIN
- (GCFSTarget_DocumentsTarget *)encodedDocumentsTarget:(FSTQuery *)query {
GCFSTarget_DocumentsTarget *result = [GCFSTarget_DocumentsTarget message];
NSMutableArray<NSString *> *docs = result.documentsArray;
- [docs addObject:[self encodedQueryPath:query.path]];
+ [docs addObject:[self encodedQueryPath:[FSTResourcePath
+ resourcePathWithCPPResourcePath:query.path]]];
return result;
}
@@ -664,16 +665,17 @@ NS_ASSUME_NONNULL_BEGIN
(unsigned long)documents.count);
NSString *name = documents[0];
- return [FSTQuery queryWithPath:[self decodedQueryPath:name]];
+ return [FSTQuery queryWithPath:[[self decodedQueryPath:name] toCPPResourcePath]];
}
- (GCFSTarget_QueryTarget *)encodedQueryTarget:(FSTQuery *)query {
// Dissect the path into parent, collectionId, and optional key filter.
GCFSTarget_QueryTarget *queryTarget = [GCFSTarget_QueryTarget message];
- if (query.path.length == 0) {
- queryTarget.parent = [self encodedQueryPath:query.path];
+ if (query.path.empty()) {
+ queryTarget.parent =
+ [self encodedQueryPath:[FSTResourcePath resourcePathWithCPPResourcePath:query.path]];
} else {
- FSTResourcePath *path = query.path;
+ FSTResourcePath *path = [FSTResourcePath resourcePathWithCPPResourcePath:query.path];
FSTAssert(path.length % 2 != 0, @"Document queries with filters are not supported.");
queryTarget.parent = [self encodedQueryPath:[path pathByRemovingLastSegment]];
GCFSStructuredQuery_CollectionSelector *from = [GCFSStructuredQuery_CollectionSelector message];
@@ -749,7 +751,7 @@ NS_ASSUME_NONNULL_BEGIN
endAt = [self decodedBound:query.endAt];
}
- return [[FSTQuery alloc] initWithPath:path
+ return [[FSTQuery alloc] initWithPath:[path toCPPResourcePath]
filterBy:filterBy
orderBy:orderBy
limit:limit
@@ -818,7 +820,7 @@ NS_ASSUME_NONNULL_BEGIN
- (GCFSStructuredQuery_Filter *)encodedRelationFilter:(FSTRelationFilter *)filter {
GCFSStructuredQuery_Filter *proto = [GCFSStructuredQuery_Filter message];
GCFSStructuredQuery_FieldFilter *fieldFilter = proto.fieldFilter;
- fieldFilter.field = [self encodedFieldPath:filter.field];
+ fieldFilter.field = [self encodedFieldPath:[FSTFieldPath fieldPathWithCPPFieldPath:filter.field]];
fieldFilter.op = [self encodedRelationFilterOperator:filter.filterOperator];
fieldFilter.value = [self encodedFieldValue:filter.value];
return proto;
@@ -828,12 +830,15 @@ NS_ASSUME_NONNULL_BEGIN
FSTFieldPath *fieldPath = [FSTFieldPath pathWithServerFormat:proto.field.fieldPath];
FSTRelationFilterOperator filterOperator = [self decodedRelationFilterOperator:proto.op];
FSTFieldValue *value = [self decodedFieldValue:proto.value];
- return [FSTRelationFilter filterWithField:fieldPath filterOperator:filterOperator value:value];
+ return [FSTRelationFilter filterWithField:[fieldPath toCPPFieldPath]
+ filterOperator:filterOperator
+ value:value];
}
- (GCFSStructuredQuery_Filter *)encodedUnaryFilter:(id<FSTFilter>)filter {
GCFSStructuredQuery_Filter *proto = [GCFSStructuredQuery_Filter message];
- proto.unaryFilter.field = [self encodedFieldPath:filter.field];
+ proto.unaryFilter.field =
+ [self encodedFieldPath:[FSTFieldPath fieldPathWithCPPFieldPath:filter.field]];
if ([filter isKindOfClass:[FSTNanFilter class]]) {
proto.unaryFilter.op = GCFSStructuredQuery_UnaryFilter_Operator_IsNan;
} else if ([filter isKindOfClass:[FSTNullFilter class]]) {
@@ -848,10 +853,10 @@ NS_ASSUME_NONNULL_BEGIN
FSTFieldPath *field = [FSTFieldPath pathWithServerFormat:proto.field.fieldPath];
switch (proto.op) {
case GCFSStructuredQuery_UnaryFilter_Operator_IsNan:
- return [[FSTNanFilter alloc] initWithField:field];
+ return [[FSTNanFilter alloc] initWithField:[field toCPPFieldPath]];
case GCFSStructuredQuery_UnaryFilter_Operator_IsNull:
- return [[FSTNullFilter alloc] initWithField:field];
+ return [[FSTNullFilter alloc] initWithField:[field toCPPFieldPath]];
default:
FSTFail(@"Unrecognized UnaryFilter.operator %d", proto.op);
@@ -920,7 +925,7 @@ NS_ASSUME_NONNULL_BEGIN
- (GCFSStructuredQuery_Order *)encodedSortOrder:(FSTSortOrder *)sortOrder {
GCFSStructuredQuery_Order *proto = [GCFSStructuredQuery_Order message];
- proto.field = [self encodedFieldPath:sortOrder.field];
+ proto.field = [self encodedFieldPath:[FSTFieldPath fieldPathWithCPPFieldPath:sortOrder.field]];
if (sortOrder.ascending) {
proto.direction = GCFSStructuredQuery_Direction_Ascending;
} else {
@@ -942,7 +947,7 @@ NS_ASSUME_NONNULL_BEGIN
default:
FSTFail(@"Unrecognized GCFSStructuredQuery_Direction %d", proto.direction);
}
- return [FSTSortOrder sortOrderWithFieldPath:fieldPath ascending:ascending];
+ return [FSTSortOrder sortOrderWithFieldPath:[fieldPath toCPPFieldPath] ascending:ascending];
}
#pragma mark - Bounds/Cursors