Skip to content

Commit

Permalink
CBL-5927 : Fix Duplicate CBLQueryIndex Interface Definition (#3300)
Browse files Browse the repository at this point in the history
* Fixed the circular reference b/w CBLCollection and CBLQueryIndex.
* Fixed warning in tests.
  • Loading branch information
pasin authored Jul 2, 2024
1 parent 6b109de commit 9cf63e0
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CouchbaseLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4325,6 +4325,8 @@
93FD618A2020757500E7F6A1 /* CBLIndex.m */,
93FD615F20204E3600E7F6A1 /* CBLIndexBuilder.h */,
93FD616020204E3600E7F6A1 /* CBLIndexBuilder.m */,
AE83D07A2C06242F0055D2CF /* CBLQueryIndex.h */,
AE83D07B2C06242F0055D2CF /* CBLQueryIndex.mm */,
93EC42CB1FB3801E00D54BB4 /* CBLValueIndex.h */,
93EC42CC1FB3801E00D54BB4 /* CBLValueIndex.m */,
1A3470BF266F3E7C0042C6BA /* CBLIndexConfiguration.h */,
Expand All @@ -4333,8 +4335,6 @@
1A3471482671C87F0042C6BA /* CBLFullTextIndexConfiguration.m */,
1A34715C2671C9230042C6BA /* CBLValueIndexConfiguration.h */,
1A34715D2671C9230042C6BA /* CBLValueIndexConfiguration.m */,
AE83D07A2C06242F0055D2CF /* CBLQueryIndex.h */,
AE83D07B2C06242F0055D2CF /* CBLQueryIndex.mm */,
);
name = Index;
sourceTree = "<group>";
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/CBLCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// limitations under the License.
//

#import <Foundation/Foundation.h>
#import <CouchbaseLite/CBLCollectionChangeObservable.h>
#import <CouchbaseLite/CBLIndexable.h>
#import <CouchbaseLite/CBLCollectionTypes.h>
Expand All @@ -27,7 +28,6 @@
@class CBLDocumentFragment;
@class CBLMutableDocument;
@class CBLScope;
@class CBLQueryIndex;
@protocol CBLListenerToken;

NS_ASSUME_NONNULL_BEGIN
Expand Down
1 change: 0 additions & 1 deletion Objective-C/CBLCollection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#import "CBLDocumentChangeNotifier.h"
#import "CBLDocument+Internal.h"
#import "CBLErrorMessage.h"
#import "CBLIndexable.h"
#import "CBLIndexConfiguration+Internal.h"
#import "CBLIndex+Internal.h"
#import "CBLQueryIndex+Internal.h"
Expand Down
9 changes: 6 additions & 3 deletions Objective-C/CBLIndexable.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
// limitations under the License.
//

#import <CouchbaseLite/CBLIndexConfiguration.h>
#import <CouchbaseLite/CBLIndex.h>
#import <CouchbaseLite/CBLQueryIndex.h>
#import <Foundation/Foundation.h>

@class CBLIndex;
@class CBLIndexConfiguration;
@class CBLQueryIndex;

NS_ASSUME_NONNULL_BEGIN

/** The Indexable interface defines a set of functions for managing the query indexes. */
@protocol CBLIndexable <NSObject>

Expand Down
3 changes: 2 additions & 1 deletion Objective-C/CBLQueryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
//

#import <Foundation/Foundation.h>
#import <CouchbaseLite/CBLCollection.h>

#ifdef COUCHBASE_ENTERPRISE
#import <CouchbaseLite/CBLIndexUpdater.h>
#endif

@class CBLCollection;

NS_ASSUME_NONNULL_BEGIN

/**
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/Tests/DatabaseTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ - (void) testCopyToExistingDatabase {
Assert(nudb, @"Cannot open the new database: %@", error);

[self expectError: NSPOSIXErrorDomain code: EEXIST in: ^BOOL(NSError** error2) {
return [CBLDatabase copyFromPath: _db.path toDatabase: dbName withConfig: config error: error2];
return [CBLDatabase copyFromPath: self->_db.path toDatabase: dbName withConfig: config error: error2];
}];

// Clean up:
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 @@ -111,7 +111,7 @@ - (void) testCreateDocWithEmptyStringID {
__block NSError *error = nil;
// to skip test exception breakpoint
[self ignoreException:^{
AssertFalse([_db saveDocument: doc error: &error]);
AssertFalse([self->_db saveDocument: doc error: &error]);
}];
AssertEqual(error.code, CBLErrorBadDocID);
AssertEqualObjects(error.domain, CBLErrorDomain);
Expand Down Expand Up @@ -1558,7 +1558,7 @@ - (void) testPurgeDocument {

// Purge before save:
[self expectError: CBLErrorDomain code: CBLErrorNotFound in: ^BOOL(NSError** err) {
return [_db purgeDocument: doc1 error: err];
return [self->_db purgeDocument: doc1 error: err];
}];

// Save:
Expand Down
1 change: 0 additions & 1 deletion Swift/Collection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public final class Collection : CollectionChangeObservable, Indexable, Equatable
/// the database is closed.
public func save(document: MutableDocument,
conflictHandler: @escaping (MutableDocument, Document?) -> Bool) throws -> Bool {

var error: NSError?
let result = impl.save(
document.impl as! CBLMutableDocument,
Expand Down

0 comments on commit 9cf63e0

Please sign in to comment.