Skip to content

Commit

Permalink
Change createIndex:forName to createIndex:withName
Browse files Browse the repository at this point in the history
Grammatically, it shoud be createIndex:withName not createIndex:forName.

#1876
  • Loading branch information
pasin committed Sep 1, 2017
1 parent 0a18f09 commit 4b051bc
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Objective-C/CBLDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ typedef NS_ENUM(uint32_t, CBLLogLevel) {
@param error error On return, the error if any.
@return True on success, false on failure.
*/
- (BOOL) createIndex: (CBLIndex*)index forName: (NSString*)name error: (NSError**)error;
- (BOOL) createIndex: (CBLIndex*)index withName: (NSString*)name error: (NSError**)error;


/**
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/CBLDatabase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ - (void) removeChangeListener: (id<NSObject>)listener {
}


- (BOOL) createIndex: (CBLIndex*)index forName: (NSString*)name error: (NSError**)outError {
- (BOOL) createIndex: (CBLIndex*)index withName: (NSString*)name error: (NSError**)outError {
[self mustBeOpen];

NSData* json = [NSJSONSerialization dataWithJSONObject: index.indexItems
Expand Down
22 changes: 11 additions & 11 deletions Objective-C/Tests/DatabaseTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1300,14 +1300,14 @@ - (void) testCreateIndex {
NSError* error;

CBLIndex* index1 = [CBLIndex valueIndexOn: @[fNameItem, lNameItem]];
Assert([self.db createIndex: index1 forName: @"index1" error: &error],
Assert([self.db createIndex: index1 withName: @"index1" error: &error],
@"Error when creating value index: %@", error);

// Create FTS index:
CBLQueryExpression* detail = [CBLQueryExpression property: @"detail"];
CBLFTSIndexItem* detailItem = [CBLFTSIndexItem expression: detail];
CBLIndex* index2 = [CBLIndex ftsIndexOn: detailItem options: nil];
Assert([self.db createIndex: index2 forName: @"index2" error: &error],
Assert([self.db createIndex: index2 withName: @"index2" error: &error],
@"Error when creating FTS index without options: %@", error);

CBLQueryExpression* detail2 = [CBLQueryExpression property: @"es-detail"];
Expand All @@ -1316,7 +1316,7 @@ - (void) testCreateIndex {
options.locale = @"es";
options.ignoreAccents = YES;
CBLIndex* index3 = [CBLIndex ftsIndexOn: detailItem2 options: options];
Assert([self.db createIndex: index3 forName: @"index3" error: &error],
Assert([self.db createIndex: index3 withName: @"index3" error: &error],
@"Error when creating FTS index with options: %@", error);

NSArray* names = self.db.indexes;
Expand All @@ -1331,11 +1331,11 @@ - (void) testCreateSameIndexTwice {
CBLValueIndexItem* item = [CBLValueIndexItem expression:
[CBLQueryExpression property: @"firstName"]];
CBLIndex* index = [CBLIndex valueIndexOn: @[item]];
Assert([self.db createIndex: index forName: @"myindex" error: &error],
Assert([self.db createIndex: index withName: @"myindex" error: &error],
@"Error when creating value index: %@", error);

// Call create index again:
Assert([self.db createIndex: index forName: @"myindex" error: &error],
Assert([self.db createIndex: index withName: @"myindex" error: &error],
@"Error when creating value index: %@", error);

NSArray* names = self.db.indexes;
Expand All @@ -1354,13 +1354,13 @@ - (void) testCreateSameNameIndexes {
// Create value index with first name:
CBLValueIndexItem* fNameItem = [CBLValueIndexItem expression: fName];
CBLIndex* fNameIndex = [CBLIndex valueIndexOn: @[fNameItem]];
Assert([self.db createIndex: fNameIndex forName: @"myindex" error: &error],
Assert([self.db createIndex: fNameIndex withName: @"myindex" error: &error],
@"Error when creating value index: %@", error);

// Create value index with last name:
CBLValueIndexItem* lNameItem = [CBLValueIndexItem expression: lName];
CBLIndex* lNameIndex = [CBLIndex valueIndexOn: @[lNameItem]];
Assert([self.db createIndex: lNameIndex forName: @"myindex" error: &error],
Assert([self.db createIndex: lNameIndex withName: @"myindex" error: &error],
@"Error when creating value index: %@", error);

// Check:
Expand All @@ -1371,7 +1371,7 @@ - (void) testCreateSameNameIndexes {
// Create FTS index:
CBLFTSIndexItem* detailItem = [CBLFTSIndexItem expression: detail];
CBLIndex* detailIndex = [CBLIndex ftsIndexOn: detailItem options: nil];
Assert([self.db createIndex: detailIndex forName: @"myindex" error: &error],
Assert([self.db createIndex: detailIndex withName: @"myindex" error: &error],
@"Error when creating FTS index without options: %@", error);

// Check:
Expand All @@ -1395,14 +1395,14 @@ - (void) testDeleteIndex {
NSError* error;

CBLIndex* index1 = [CBLIndex valueIndexOn: @[fNameItem, lNameItem]];
Assert([self.db createIndex: index1 forName: @"index1" error: &error],
Assert([self.db createIndex: index1 withName: @"index1" error: &error],
@"Error when creating value index: %@", error);

// Create FTS index:
CBLQueryExpression* detail = [CBLQueryExpression property: @"detail"];
CBLFTSIndexItem* detailItem = [CBLFTSIndexItem expression: detail];
CBLIndex* index2 = [CBLIndex ftsIndexOn: detailItem options: nil];
Assert([self.db createIndex: index2 forName: @"index2" error: &error],
Assert([self.db createIndex: index2 withName: @"index2" error: &error],
@"Error when creating FTS index without options: %@", error);

CBLQueryExpression* detail2 = [CBLQueryExpression property: @"es-detail"];
Expand All @@ -1411,7 +1411,7 @@ - (void) testDeleteIndex {
options.locale = @"es";
options.ignoreAccents = YES;
CBLIndex* index3 = [CBLIndex ftsIndexOn: detail2Item options: options];
Assert([self.db createIndex: index3 forName: @"index3" error: &error],
Assert([self.db createIndex: index3 withName: @"index3" error: &error],
@"Error when creating FTS index with options: %@", error);

NSArray* names = self.db.indexes;
Expand Down
8 changes: 4 additions & 4 deletions Objective-C/Tests/PredicateQueryTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (void) testPredicates {
NSError* error;
CBLQueryExpression* blurb = [CBLQueryExpression property: @"blurb"];
CBLIndex* index = [CBLIndex ftsIndexOn: [CBLFTSIndexItem expression: blurb] options: nil];
Assert([_db createIndex: index forName: @"blurb" error: &error]);
Assert([_db createIndex: index withName: @"blurb" error: &error]);

const struct {const char *pred; const char *json5;} kTests[] = {
{"nickname == 'Bobo'", "{WHERE: ['=', ['.nickname'],'Bobo']}"},
Expand Down Expand Up @@ -213,7 +213,7 @@ - (void) propertyQueryWithReopen: (BOOL)reopen {
}];
AssertEqual(numRows, 1llu);
if (pass == 0)
Assert([_db createIndex: index forName: @"name.first" error: &error]);
Assert([_db createIndex: index withName: @"name.first" error: &error]);
}

Assert([self.db deleteIndexForName: @"name.first" error: &error]);
Expand Down Expand Up @@ -248,7 +248,7 @@ - (void) testFTS {
NSError* error;
CBLQueryExpression* sentence = [CBLQueryExpression property: @"sentence"];
CBLIndex* index = [CBLIndex ftsIndexOn: [CBLFTSIndexItem expression: sentence] options: nil];
Assert([_db createIndex: index forName: @"sentence" error: &error]);
Assert([_db createIndex: index withName: @"sentence" error: &error]);

CBLPredicateQuery *q = [self.db createQueryWhere: @"sentence matches 'Dummie woman'"];
q.orderBy = @[@"-rank(sentence)"];
Expand All @@ -272,7 +272,7 @@ - (void) testDeleteQueriedDoc {
NSError* error;
CBLQueryExpression* firstName = [CBLQueryExpression property: @"name.first"];
CBLIndex* index = [CBLIndex valueIndexOn: @[[CBLValueIndexItem expression: firstName]]];
Assert([_db createIndex: index forName: @"name.first" error: &error]);
Assert([_db createIndex: index withName: @"name.first" error: &error]);

CBLPredicateQuery *q = [self.db createQueryWhere: @"name.first == $FIRSTNAME"];
q.parameters = @{@"FIRSTNAME": @"Claude"};
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/Tests/QueryTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ - (void) testWhereMatch {

NSError* error;
CBLIndex* index = [CBLIndex ftsIndexOn: [CBLFTSIndexItem expression: SENTENCE] options: nil];
Assert([self.db createIndex: index forName: @"sentence" error: &error],
Assert([self.db createIndex: index withName: @"sentence" error: &error],
@"Error when creating the index: %@", error);


Expand Down
4 changes: 2 additions & 2 deletions Objective-C/Tests/TunesPerfTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ - (void) createArtistsIndex {
#endif
CBLIndex *index = [CBLIndex valueIndexOn: @[[CBLValueIndexItem expression: artist],
[CBLValueIndexItem expression: comp]]];
Assert(([self.db createIndex: index forName: @"byArtist" error: NULL]));
Assert(([self.db createIndex: index withName: @"byArtist" error: NULL]));
double t = _indexArtistsBench.stop();
VerboseLog(1, @"Indexed artists in %.06f sec", t);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ - (unsigned) fullTextSearch {
CBLQueryExpression* nameExpr = [CBLQueryExpression property: @"Name"];
CBLIndex *index = [CBLIndex ftsIndexOn: [CBLFTSIndexItem expression: nameExpr]
options: nil];
Assert(([self.db createIndex: index forName: @"nameFTS" error: &error]),
Assert(([self.db createIndex: index withName: @"nameFTS" error: &error]),
@"Full-text indexing failed: %@", error);
_indexFTSBench.stop();
[self pause];
Expand Down
4 changes: 2 additions & 2 deletions Swift/Database+Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ extension Database {
/// - index: The index.
/// - name: The index name.
/// - Throws: An error on a failure.
public func createIndex(_ index: Index, forName name: String) throws {
public func createIndex(_ index: Index, withName name: String) throws {

try _impl.createIndex(index.impl, forName: name)
try _impl.createIndex(index.impl, withName: name)
}


Expand Down
22 changes: 11 additions & 11 deletions Swift/Tests/DatabaseTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ class DatabaseTest: CBLTestCase {
let lNameItem = ValueIndexItem.expression(Expression.property("lastName"))

let index1 = Index.valueIndex().on(fNameItem, lNameItem)
try db.createIndex(index1, forName: "index1")
try db.createIndex(index1, withName: "index1")

// Create FTS index:
let detailItem = FTSIndexItem.expression(Expression.property("detail"))
let index2 = Index.ftsIndex().on(detailItem)
try db.createIndex(index2, forName: "index2")
try db.createIndex(index2, withName: "index2")

let detailItem2 = FTSIndexItem.expression(Expression.property("es-detail"))
let index3 = Index.ftsIndex().on(detailItem2).locale("es").ignoreAccents(true)
try db.createIndex(index3, forName: "index3")
try db.createIndex(index3, withName: "index3")

XCTAssertEqual(db.indexes.count, 3)
XCTAssertEqual(db.indexes, ["index1", "index2", "index3"])
Expand All @@ -124,10 +124,10 @@ class DatabaseTest: CBLTestCase {

// Create index with first name:
let index = Index.valueIndex().on(item)
try db.createIndex(index, forName: "myindex")
try db.createIndex(index, withName: "myindex")

// Call create index again:
try db.createIndex(index, forName: "myindex")
try db.createIndex(index, withName: "myindex")

XCTAssertEqual(db.indexes.count, 1)
XCTAssertEqual(db.indexes, ["myindex"])
Expand All @@ -137,12 +137,12 @@ class DatabaseTest: CBLTestCase {
// Create value index with first name:
let fNameItem = ValueIndexItem.expression(Expression.property("firstName"))
let fNameIndex = Index.valueIndex().on(fNameItem)
try db.createIndex(fNameIndex, forName: "myindex")
try db.createIndex(fNameIndex, withName: "myindex")

// Create value index with last name:
let lNameItem = ValueIndexItem.expression(Expression.property("lastName"))
let lNameIndex = Index.valueIndex().on(lNameItem)
try db.createIndex(lNameIndex, forName: "myindex")
try db.createIndex(lNameIndex, withName: "myindex")

// Check:
XCTAssertEqual(db.indexes.count, 1)
Expand All @@ -151,7 +151,7 @@ class DatabaseTest: CBLTestCase {
// Create FTS index:
let detailItem = FTSIndexItem.expression(Expression.property("detail"))
let detailIndex = Index.ftsIndex().on(detailItem)
try db.createIndex(detailIndex, forName: "myindex")
try db.createIndex(detailIndex, withName: "myindex")

// Check:
XCTAssertEqual(db.indexes.count, 1)
Expand All @@ -167,16 +167,16 @@ class DatabaseTest: CBLTestCase {
let lNameItem = ValueIndexItem.expression(Expression.property("lastName"))

let index1 = Index.valueIndex().on(fNameItem, lNameItem)
try db.createIndex(index1, forName: "index1")
try db.createIndex(index1, withName: "index1")

// Create FTS index:
let detailItem = FTSIndexItem.expression(Expression.property("detail"))
let index2 = Index.ftsIndex().on(detailItem)
try db.createIndex(index2, forName: "index2")
try db.createIndex(index2, withName: "index2")

let detailItem2 = FTSIndexItem.expression(Expression.property("es-detail"))
let index3 = Index.ftsIndex().on(detailItem2).locale("es").ignoreAccents(true)
try db.createIndex(index3, forName: "index3")
try db.createIndex(index3, withName: "index3")

XCTAssertEqual(db.indexes.count, 3)
XCTAssertEqual(db.indexes, ["index1", "index2", "index3"])
Expand Down
2 changes: 1 addition & 1 deletion Swift/Tests/PredicateQueryTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PredicateQueryTest: CBLTestCase {

let item = ValueIndexItem.expression(Expression.property("name.first"))
let index = Index.valueIndex().on(item)
try db.createIndex(index, forName: "name.first")
try db.createIndex(index, withName: "name.first")
}
}

Expand Down
2 changes: 1 addition & 1 deletion Swift/Tests/QueryTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class QueryTest: CBLTestCase {
.on(FTSIndexItem.expression(Expression.property("sentence")))
.locale(nil)
.ignoreAccents(false)
try db.createIndex(index, forName: "sentence")
try db.createIndex(index, withName: "sentence")

let sentence = Expression.property("sentence")
let s_sentence = SelectResult.expression(sentence)
Expand Down

0 comments on commit 4b051bc

Please sign in to comment.