From 2b1a87250e3bb5f26838df428443f80ed7c5b916 Mon Sep 17 00:00:00 2001 From: Vlad Velicu Date: Thu, 14 Nov 2024 18:41:08 +0000 Subject: [PATCH] last fixes --- Objective-C/CBLDocument.mm | 14 +++++++++----- Objective-C/Tests/DatabaseTest.m | 8 -------- Objective-C/Tests/DocumentTest.m | 5 ++--- Objective-C/Tests/VectorSearchTest.m | 2 +- Swift/Document.swift | 2 +- Swift/Tests/DocumentTest.swift | 5 ++--- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Objective-C/CBLDocument.mm b/Objective-C/CBLDocument.mm index 4f0efee12..778a5148a 100644 --- a/Objective-C/CBLDocument.mm +++ b/Objective-C/CBLDocument.mm @@ -201,12 +201,16 @@ - (void) replaceC4Doc: (CBLC4Document*)c4doc { } - (nullable NSString*) _getRevisionHistory { + if (!_collection) { + return nil; + } + CBL_LOCK(self) { - if (!_c4Doc) { - return nil; - } else { - return sliceResult2string(c4doc_getRevisionHistory(_c4Doc.rawDoc, UINT_MAX, nil, 0)); - } + C4Error err; + C4Document* doc = c4coll_getDoc(_collection.c4col, _c4Doc.docID, true, kDocGetAll, &err); + NSString* revHistory = doc ? sliceResult2string(c4doc_getRevisionHistory(doc, UINT_MAX, nil, 0)) : nil; + c4doc_release(doc); + return revHistory; } } diff --git a/Objective-C/Tests/DatabaseTest.m b/Objective-C/Tests/DatabaseTest.m index 29cae4697..861f9b41a 100644 --- a/Objective-C/Tests/DatabaseTest.m +++ b/Objective-C/Tests/DatabaseTest.m @@ -598,14 +598,6 @@ - (void) testSavePurgedDoc { #pragma mark Save Conflict Handler -- (NSTimeInterval) checkTimestampUpdated:(CBLDocument*) doc - :(NSTimeInterval) oldTimestamp { - NSTimeInterval docTimestamp = doc.timestamp; - Assert(docTimestamp > oldTimestamp); - - return docTimestamp; -} - - (void) testConflictHandler { NSError* error; NSString* docID = @"doc1"; diff --git a/Objective-C/Tests/DocumentTest.m b/Objective-C/Tests/DocumentTest.m index 0528027b1..84244ea07 100644 --- a/Objective-C/Tests/DocumentTest.m +++ b/Objective-C/Tests/DocumentTest.m @@ -2320,9 +2320,8 @@ - (void) testDocumentRevisionHistory { Assert([defaultCollection saveDocument:doc error: &err]); Assert(doc._getRevisionHistory); - // Fails from LiteCore,only 1 rev, no rev history - // doc = [[defaultCollection documentWithID: @"doc1" error: &err] toMutable]; - // Assert(doc._getRevisionHistory); + doc = [[defaultCollection documentWithID: @"doc1" error: &err] toMutable]; + Assert(doc._getRevisionHistory); } #pragma clang diagnostic pop diff --git a/Objective-C/Tests/VectorSearchTest.m b/Objective-C/Tests/VectorSearchTest.m index 65cf91221..265b6d127 100644 --- a/Objective-C/Tests/VectorSearchTest.m +++ b/Objective-C/Tests/VectorSearchTest.m @@ -1188,7 +1188,7 @@ - (void) testVectorMatchLimitBoundary { // Check if error thrown for wrong limit values [self expectError: CBLErrorDomain code: CBLErrorInvalidQuery in: ^BOOL(NSError** err) { - NSString* sql = [self wordsQueryStringWithLimit: @10001]; + NSString* sql = [self wordsQueryStringWithLimit: 10001]; return [self.wordDB createQuery: sql error: err] != nil; }]; } diff --git a/Swift/Document.swift b/Swift/Document.swift index 73f1abcd1..41ecddf44 100644 --- a/Swift/Document.swift +++ b/Swift/Document.swift @@ -33,7 +33,7 @@ public class Document : DictionaryProtocol, Equatable, Hashable, Sequence { return impl.revisionID } - public var timestamp: Double { + public var timestamp: TimeInterval { return impl.timestamp } diff --git a/Swift/Tests/DocumentTest.swift b/Swift/Tests/DocumentTest.swift index c0f57e4cf..025ee1800 100644 --- a/Swift/Tests/DocumentTest.swift +++ b/Swift/Tests/DocumentTest.swift @@ -1901,8 +1901,7 @@ class DocumentTest: CBLTestCase { try defaultCollection!.save(document: doc) assert(doc._getRevisionHistory() != nil) - // Fails from LiteCore,only 1 rev, no rev history - // doc = try defaultCollection!.document(id: "doc1")!.toMutable(); - // asser(doc._getRevisionHistory() != nil) + doc = try defaultCollection!.document(id: "doc1")!.toMutable(); + assert(doc._getRevisionHistory() != nil) } }