Skip to content
This repository was archived by the owner on May 20, 2021. It is now read-only.

Commit cdce5fb

Browse files
committed
Properly handle unordered relationship in METIncrementalStore
1 parent 3022aae commit cdce5fb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Meteor/METIncrementalStore.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -279,23 +279,23 @@ - (id)objectIDForToOneRelationship:(NSRelationshipDescription *)relationship inD
279279
return [NSNull null];
280280
}
281281

282-
- (NSArray *)objectIDsForToManyRelationship:(NSRelationshipDescription *)relationship forObjectWithID:(NSManagedObjectID *)objectID {
282+
- (id)objectIDsForToManyRelationship:(NSRelationshipDescription *)relationship forObjectWithID:(NSManagedObjectID *)objectID {
283+
NSMutableArray *objectIDs = [[NSMutableArray alloc] init];
283284
if ([self sourceDocumentStoresReferenceFieldForRelationship:relationship]) {
284285
METDocument *document = [self documentForObjectWithID:objectID];
285-
return [self objectIDsForToManyRelationship:relationship inDocument:document];
286+
[objectIDs addObjectsFromArray:[self objectIDsForToManyRelationship:relationship inDocument:document]];
286287
} else {
287288
NSRelationshipDescription *inverseRelationship = relationship.inverseRelationship;
288289
NSString *sourceDocumentID = [self documentKeyForObjectID:objectID].documentID;
289290
NSArray *destinationDocuments = [self documentsForEntity:relationship.destinationEntity];
290291
NSString *fieldName = [self fieldNameForRelationship:inverseRelationship];
291-
NSMutableArray *objectIDs = [[NSMutableArray alloc] init];
292292
for (METDocument *document in destinationDocuments) {
293293
if ([document[fieldName] isEqual:sourceDocumentID]) {
294294
[objectIDs addObject:[self objectIDForDocument:document]];
295295
}
296296
}
297-
return objectIDs;
298297
}
298+
return relationship.isOrdered ? objectIDs : [NSSet setWithArray:objectIDs];
299299
}
300300

301301
- (NSArray *)objectIDsForToManyRelationship:(NSRelationshipDescription *)relationship inDocument:(METDocument *)document {

0 commit comments

Comments
 (0)