Skip to content

Commit 58c0a6b

Browse files
committed
Removing setPrimitive methods, which have been fundamentally broken since the addition of extensions. Replacing them with advanced setObject methods that allow one to pass pre-serialized versions of the object and/or metadata. Also renaming the primitive accessors to use the new serializedObject / serializedMetadata terminology. Fixes issue #23
1 parent 11169ab commit 58c0a6b

File tree

5 files changed

+869
-793
lines changed

5 files changed

+869
-793
lines changed

Testing/UnitTesting/TestYapDatabase.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ - (void)test1
6969
XCTAssertTrue([transaction numberOfKeysInCollection:nil] == 0, @"Expected zero key count");
7070

7171
XCTAssertNil([transaction objectForKey:@"non-existant" inCollection:nil], @"Expected nil object");
72-
XCTAssertNil([transaction primitiveDataForKey:@"non-existant" inCollection:nil], @"Expected nil data");
72+
XCTAssertNil([transaction serializedObjectForKey:@"non-existant" inCollection:nil], @"Expected nil data");
7373

7474
XCTAssertFalse([transaction hasObjectForKey:@"non-existant" inCollection:nil], @"Expected NO object for key");
7575

@@ -125,7 +125,7 @@ - (void)test1
125125
XCTAssertTrue([[transaction allKeysInCollection:@""] count] == 1, @"Expected 1 key");
126126

127127
XCTAssertNotNil([transaction objectForKey:key1 inCollection:nil], @"Expected non-nil object");
128-
XCTAssertNotNil([transaction primitiveDataForKey:key1 inCollection:nil], @"Expected non-nil data");
128+
XCTAssertNotNil([transaction serializedObjectForKey:key1 inCollection:nil], @"Expected non-nil data");
129129

130130
XCTAssertTrue([transaction hasObjectForKey:key1 inCollection:nil], @"Expected YES");
131131

@@ -166,7 +166,7 @@ - (void)test1
166166
XCTAssertTrue([[transaction allKeysInCollection:nil] count] == 0, @"Expected 0 keys");
167167

168168
XCTAssertNil([transaction objectForKey:key1 inCollection:nil], @"Expected nil object");
169-
XCTAssertNil([transaction primitiveDataForKey:key1 inCollection:nil], @"Expected nil data");
169+
XCTAssertNil([transaction serializedObjectForKey:key1 inCollection:nil], @"Expected nil data");
170170

171171
XCTAssertFalse([transaction hasObjectForKey:key1 inCollection:nil], @"Expected NO");
172172
}];
@@ -181,7 +181,7 @@ - (void)test1
181181
XCTAssertTrue([[transaction allKeysInCollection:nil] count] == 1, @"Expected 1 key");
182182

183183
XCTAssertNotNil([transaction objectForKey:key1 inCollection:nil], @"Expected non-nil object");
184-
XCTAssertNotNil([transaction primitiveDataForKey:key1 inCollection:nil], @"Expected non-nil data");
184+
XCTAssertNotNil([transaction serializedObjectForKey:key1 inCollection:nil], @"Expected non-nil data");
185185

186186
XCTAssertTrue([transaction hasObjectForKey:key1 inCollection:nil], @"Expected YES");
187187

YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,8 @@ - (void)flush
23782378
[databaseRwTransaction replaceObject:updatedDestinationNode
23792379
forKey:edge->destinationKey
23802380
inCollection:edge->destinationCollection
2381-
withRowid:edge->destinationRowid];
2381+
withRowid:edge->destinationRowid
2382+
serializedObject:nil];
23822383
}
23832384
}
23842385
}
@@ -2437,7 +2438,8 @@ - (void)flush
24372438
[databaseRwTransaction replaceObject:updatedSourceNode
24382439
forKey:edge->sourceKey
24392440
inCollection:edge->sourceCollection
2440-
withRowid:edge->sourceRowid];
2441+
withRowid:edge->sourceRowid
2442+
serializedObject:nil];
24412443
}
24422444
}
24432445
}
@@ -2753,7 +2755,8 @@ - (void)flush
27532755
[databaseRwTransaction replaceObject:updatedDstNode
27542756
forKey:edge->destinationKey
27552757
inCollection:edge->destinationCollection
2756-
withRowid:edge->destinationRowid];
2758+
withRowid:edge->destinationRowid
2759+
serializedObject:nil];
27572760
}
27582761
}
27592762
}
@@ -2839,7 +2842,8 @@ - (void)flush
28392842
[databaseRwTransaction replaceObject:updatedSrcNode
28402843
forKey:edge->sourceKey
28412844
inCollection:edge->sourceCollection
2842-
withRowid:edge->sourceRowid];
2845+
withRowid:edge->sourceRowid
2846+
serializedObject:nil];
28432847
}
28442848
}
28452849
}

YapDatabase/Internal/YapDatabasePrivate.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,17 @@ extern NSString *const YapDatabaseNotificationKey;
439439
id customObjectForNotification;
440440
}
441441

442-
- (void)replaceObject:(id)object forKey:(NSString *)key inCollection:(NSString *)collection withRowid:(int64_t)rowid;
442+
- (void)replaceObject:(id)object
443+
forKey:(NSString *)key
444+
inCollection:(NSString *)collection
445+
withRowid:(int64_t)rowid
446+
serializedObject:(NSData *)preSerializedObject;
447+
443448
- (void)replaceMetadata:(id)metadata
444449
forKey:(NSString *)key
445450
inCollection:(NSString *)collection
446-
withRowid:(int64_t)rowid;
451+
withRowid:(int64_t)rowid
452+
serializedMetadata:(NSData *)preSerializedMetadata;
447453

448454
- (void)removeObjectForKey:(NSString *)key inCollection:(NSString *)collection withRowid:(int64_t)rowid;
449455

0 commit comments

Comments
 (0)