Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBL-5181: Array Index API tests and adjustments #3330

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CouchbaseLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,10 @@
AE5803F92B9B969D001A1BE3 /* CouchbaseLiteVectorSearch.xcframework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 40086B152B7EDDD400DA6770 /* CouchbaseLiteVectorSearch.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
AE5803FA2B9B96BF001A1BE3 /* CouchbaseLiteVectorSearch.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 40086B152B7EDDD400DA6770 /* CouchbaseLiteVectorSearch.xcframework */; };
AE5803FB2B9B96BF001A1BE3 /* CouchbaseLiteVectorSearch.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 40086B152B7EDDD400DA6770 /* CouchbaseLiteVectorSearch.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
AE5F25582CAC310700AAB7F4 /* UnnestArrayIndexTest.m in Sources */ = {isa = PBXBuildFile; fileRef = AE5F25492CAC30DC00AAB7F4 /* UnnestArrayIndexTest.m */; };
AE5F25592CAC310800AAB7F4 /* UnnestArrayIndexTest.m in Sources */ = {isa = PBXBuildFile; fileRef = AE5F25492CAC30DC00AAB7F4 /* UnnestArrayIndexTest.m */; };
AE5F255A2CAC310900AAB7F4 /* UnnestArrayIndexTest.m in Sources */ = {isa = PBXBuildFile; fileRef = AE5F25492CAC30DC00AAB7F4 /* UnnestArrayIndexTest.m */; };
AE5F255B2CAC311100AAB7F4 /* UnnestArrayIndexTest.m in Sources */ = {isa = PBXBuildFile; fileRef = AE5F25492CAC30DC00AAB7F4 /* UnnestArrayIndexTest.m */; };
AE83D0842C0637ED0055D2CF /* CBLIndexUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = AE83D0822C0637ED0055D2CF /* CBLIndexUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; };
AE83D0852C0637ED0055D2CF /* CBLIndexUpdater.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE83D0832C0637ED0055D2CF /* CBLIndexUpdater.mm */; };
AE83D0862C0637ED0055D2CF /* CBLIndexUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = AE83D0822C0637ED0055D2CF /* CBLIndexUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand All @@ -1780,6 +1784,10 @@
AEC806BC2C89EA68001C9723 /* CBLArrayIndexConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = AEC806B62C89EA68001C9723 /* CBLArrayIndexConfiguration.m */; };
AEC806BD2C89EA68001C9723 /* CBLArrayIndexConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = AEC806B62C89EA68001C9723 /* CBLArrayIndexConfiguration.m */; };
AEC806BE2C89EA68001C9723 /* CBLArrayIndexConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = AEC806B52C89EA68001C9723 /* CBLArrayIndexConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
AECA897D2CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECA897C2CADADAA00C7B6BE /* UnnestArrayTest.swift */; };
AECA897E2CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECA897C2CADADAA00C7B6BE /* UnnestArrayTest.swift */; };
AECA897F2CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECA897C2CADADAA00C7B6BE /* UnnestArrayTest.swift */; };
AECA89802CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECA897C2CADADAA00C7B6BE /* UnnestArrayTest.swift */; };
AECD5A162C0E21D900B1247E /* CBLIndexUpdater+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = AECD5A0F2C0E21D900B1247E /* CBLIndexUpdater+Internal.h */; };
AECD5A172C0E21D900B1247E /* CBLIndexUpdater+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = AECD5A0F2C0E21D900B1247E /* CBLIndexUpdater+Internal.h */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -2798,10 +2806,12 @@
AE006DE62B7BB98B00884E2B /* VectorSearchTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VectorSearchTest.m; sourceTree = "<group>"; };
AE5803A32B99C67D001A1BE3 /* VectorSearchTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VectorSearchTest.swift; sourceTree = "<group>"; };
AE5803D72B9B5B2A001A1BE3 /* WordEmbeddingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordEmbeddingModel.swift; sourceTree = "<group>"; };
AE5F25492CAC30DC00AAB7F4 /* UnnestArrayIndexTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UnnestArrayIndexTest.m; sourceTree = "<group>"; };
AE83D0822C0637ED0055D2CF /* CBLIndexUpdater.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLIndexUpdater.h; sourceTree = "<group>"; };
AE83D0832C0637ED0055D2CF /* CBLIndexUpdater.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CBLIndexUpdater.mm; sourceTree = "<group>"; };
AEC806B52C89EA68001C9723 /* CBLArrayIndexConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLArrayIndexConfiguration.h; sourceTree = "<group>"; };
AEC806B62C89EA68001C9723 /* CBLArrayIndexConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CBLArrayIndexConfiguration.m; sourceTree = "<group>"; };
AECA897C2CADADAA00C7B6BE /* UnnestArrayTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnnestArrayTest.swift; sourceTree = "<group>"; };
AECD59F92C0E137200B1247E /* CBLQueryIndex+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CBLQueryIndex+Internal.h"; sourceTree = "<group>"; };
AECD5A0F2C0E21D900B1247E /* CBLIndexUpdater+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CBLIndexUpdater+Internal.h"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -3087,6 +3097,7 @@
1A13DD3328B8809300BC1084 /* URLEndpointListenerTest+Collection.swift */,
AE5803A32B99C67D001A1BE3 /* VectorSearchTest.swift */,
406F8DFC2C27F097000223FC /* VectorSearchTest+Lazy.swift */,
AECA897C2CADADAA00C7B6BE /* UnnestArrayTest.swift */,
1AA91DC522B0356000BF0BDE /* CustomLogger.swift */,
93249D81246B99FD000A8A6E /* iOS */,
939B79241E679017009A70EF /* Info.plist */,
Expand Down Expand Up @@ -4154,6 +4165,7 @@
40AA72A12C28B1F2007FB1E0 /* VectorSearchTest.h */,
AE006DE62B7BB98B00884E2B /* VectorSearchTest.m */,
40AA72972C28B1A3007FB1E0 /* VectorSearchTest+Lazy.m */,
AE5F25492CAC30DC00AAB7F4 /* UnnestArrayIndexTest.m */,
93DECF3E200DBE5800F44953 /* Support */,
936483AA1E4431C6008D08B3 /* iOS */,
275FF5FA1E3FBD3B005F90DD /* Performance */,
Expand Down Expand Up @@ -6212,6 +6224,7 @@
1A8F85092893F318008C4333 /* QueryTest+Collection.swift in Sources */,
93E17F151ED4ED4000671CA1 /* NotificationTest.swift in Sources */,
27BE3B4D1E4E51C80012B74A /* DatabaseTest.swift in Sources */,
AECA897D2CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */,
1A6084F828758AE00037C66F /* CollectionTest.swift in Sources */,
934C2CDE1F4FC0D20010316F /* CBLTestHelper.m in Sources */,
9388CC5521C25CC7005CA66D /* LogTest.swift in Sources */,
Expand Down Expand Up @@ -6255,6 +6268,7 @@
93BB1CB4246BB2ED004FFA00 /* ReplicatorTest.swift in Sources */,
1A6084FA28758AE20037C66F /* CollectionTest.swift in Sources */,
93BB1CB1246BB2E4004FFA00 /* PredictiveQueryTest.swift in Sources */,
AECA89802CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */,
93BB1CBA246BB2F4004FFA00 /* CustomLogger.swift in Sources */,
1A13DD4428B882BA00BC1084 /* URLEndpointListenerTest+Collection.swift in Sources */,
93BB1CA1246BB2CA004FFA00 /* DateTimeQueryFunctionTest.swift in Sources */,
Expand Down Expand Up @@ -6698,6 +6712,7 @@
9343F13B207D61EC00F19A89 /* CBLTestCase.m in Sources */,
1A4160DB22836E8C0061A567 /* ReplicatorTest+Main.m in Sources */,
930C7F9220FE4F7500C74A12 /* CBLMockConnectionErrorLogic.m in Sources */,
AE5F255A2CAC310900AAB7F4 /* UnnestArrayIndexTest.m in Sources */,
1AA6744B227924120018CC6D /* QueryTest+Join.m in Sources */,
934EF8312460D0770053A47C /* TLSIdentityTest.m in Sources */,
9343F13C207D61EC00F19A89 /* DatabaseTest.m in Sources */,
Expand Down Expand Up @@ -6772,6 +6787,7 @@
930C7F9520FE4F7500C74A12 /* CBLMockConnection.m in Sources */,
9343F179207D633300F19A89 /* QueryTest.m in Sources */,
1A621D7B2887DCFE0017F905 /* QueryTest+Collection.m in Sources */,
AE5F255B2CAC311100AAB7F4 /* UnnestArrayIndexTest.m in Sources */,
933F841E220BA4100093EC88 /* PredictiveQueryTest+CoreML.m in Sources */,
1AA3D78822AB07D80098E16B /* CustomLogger.m in Sources */,
1A2F2C3627FD5B2200084B3C /* TrustCheckTest.m in Sources */,
Expand Down Expand Up @@ -6800,6 +6816,7 @@
93EB25A421CDCC160006FB88 /* PredictiveQueryTest.swift in Sources */,
1A6084FB28758AE90037C66F /* CollectionTest.swift in Sources */,
9343F18E207D636300F19A89 /* DocumentTest.swift in Sources */,
AECA897F2CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */,
1A13DD4328B882BA00BC1084 /* URLEndpointListenerTest+Collection.swift in Sources */,
9343F18F207D636300F19A89 /* ArrayTest.swift in Sources */,
1A690CD7242150DF0084D017 /* ReplicatorTest+PendingDocIds.swift in Sources */,
Expand Down Expand Up @@ -6877,6 +6894,7 @@
1ABA63AF28813A8A005835E7 /* ReplicatorTest+Collection.m in Sources */,
1A621D792887DCFC0017F905 /* QueryTest+Collection.m in Sources */,
9388CBAC21BD917D005CA66D /* DocumentExpirationTest.m in Sources */,
AE5F25592CAC310800AAB7F4 /* UnnestArrayIndexTest.m in Sources */,
1AA67439227924110018CC6D /* QueryTest+Meta.m in Sources */,
9385F3041FC645D300032037 /* ConcurrentTest.m in Sources */,
93CD018E1E95546200AFB3FA /* QueryTest.m in Sources */,
Expand Down Expand Up @@ -7018,6 +7036,7 @@
9378C5911E25B3F0001BB196 /* DatabaseTest.m in Sources */,
1A4FE76A225ED344009D5F43 /* MiscCppTest.mm in Sources */,
1A908401288027EE006B1885 /* ReplicatorTest+Collection.m in Sources */,
AE5F25582CAC310700AAB7F4 /* UnnestArrayIndexTest.m in Sources */,
1AC83BC821C026D100792098 /* DateTimeQueryFunctionTest.m in Sources */,
938B3702200D7D1D004485D8 /* MigrationTest.m in Sources */,
1AA3D78422AB07C50098E16B /* CustomLogger.m in Sources */,
Expand Down Expand Up @@ -7051,6 +7070,7 @@
1A8F85082893F317008C4333 /* QueryTest+Collection.swift in Sources */,
93BB1CAE246BB2DC004FFA00 /* QueryTest.swift in Sources */,
93BB1CAD246BB2DC004FFA00 /* NotificationTest.swift in Sources */,
AECA897E2CADADAA00C7B6BE /* UnnestArrayTest.swift in Sources */,
1A6084F728758ADF0037C66F /* CollectionTest.swift in Sources */,
93BB1CA6246BB2D3004FFA00 /* LogTest.swift in Sources */,
93BB1CB7246BB2F3004FFA00 /* CustomLogger.swift in Sources */,
Expand Down
8 changes: 3 additions & 5 deletions Objective-C/CBLArrayIndexConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ - (instancetype) initWithPath: (NSString*) path
if(!expressions) {
self = [super initWithIndexType: kC4ArrayIndex
expressions: @[@""]];
}

if ([expressions count] == 0) {
} else if ([expressions count] == 0 || [expressions[0] length] == 0) {
[NSException raise: NSInvalidArgumentException format:
@"Expressions cannot be empty "];
@"Empty expressions is not allowed, use nil instead"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add another validation for a single empty string ? We don't allow that to be set as well. See the updated API spec.

}

self = [super initWithIndexType: kC4ArrayIndex
Expand All @@ -55,7 +53,7 @@ - (instancetype) initWithPath: (NSString*)path {

- (C4IndexOptions) indexOptions {
C4IndexOptions c4options = { };
//c4options.unnestPath = _path;
c4options.unnestPath = [_path UTF8String];
return c4options;
}

Expand Down
Loading
Loading