Skip to content

Commit

Permalink
get new c4doc using kDocGetAll content lvl
Browse files Browse the repository at this point in the history
  • Loading branch information
velicuvlad committed Oct 23, 2024
1 parent d418d8b commit 1a3d2db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions Objective-C/CBLDocument.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Objective-C/Tests/DocumentTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2292,8 +2292,8 @@ - (void) testDocumentRevisionHistory {
Assert([defaultCollection saveDocument:doc error: &err]);
Assert(doc._getRevisionHistory);

CBLDocument* remoteDoc = [defaultCollection documentWithID: @"doc1" error: &err];
Assert(remoteDoc._getRevisionHistory);
doc = [[defaultCollection documentWithID: @"doc1" error: &err] toMutable];
Assert(doc._getRevisionHistory);
}

#pragma clang diagnostic pop
Expand Down
2 changes: 1 addition & 1 deletion Swift/Tests/DocumentTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ class DocumentTest: CBLTestCase {
try defaultCollection!.save(document: doc)
assert(doc._getRevisionHistory() != nil)

let remoteDoc = try defaultCollection!.document(id: "doc1")!;
let remoteDoc = try defaultCollection!.document(id: "doc1")!.toMutable();
assert(doc._getRevisionHistory() != nil)
}
}

0 comments on commit 1a3d2db

Please sign in to comment.