Skip to content

Commit ac52569

Browse files
committed
fix create/drop index functions
1 parent 113dc21 commit ac52569

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

Sources/SQLite/Typed/Schema.swift

+2-9
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@ extension Table {
127127

128128
// MARK: - CREATE INDEX
129129

130-
public func createIndex(_ columns: Expressible...) -> String {
131-
return createIndex(columns)
132-
}
133-
134-
public func createIndex(_ columns: [Expressible], unique: Bool = false, ifNotExists: Bool = false) -> String {
130+
public func createIndex(_ columns: Expressible..., unique: Bool = false, ifNotExists: Bool = false) -> String {
135131
let clauses: [Expressible?] = [
136132
create("INDEX", indexName(columns), unique ? .unique : nil, ifNotExists),
137133
Expression<Void>(literal: "ON"),
@@ -144,11 +140,8 @@ extension Table {
144140

145141
// MARK: - DROP INDEX
146142

147-
public func dropIndex(_ columns: Expressible...) -> String {
148-
return dropIndex(columns)
149-
}
150143

151-
public func dropIndex(_ columns: [Expressible], ifExists: Bool = false) -> String {
144+
public func dropIndex(_ columns: Expressible..., ifExists: Bool = false) -> String {
152145
return drop("INDEX", indexName(columns), ifExists)
153146
}
154147

Tests/SQLiteTests/SchemaTests.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -727,25 +727,25 @@ class SchemaTests : XCTestCase {
727727

728728
XCTAssertEqual(
729729
"CREATE UNIQUE INDEX \"index_table_on_int64\" ON \"table\" (\"int64\")",
730-
table.createIndex([int64], unique: true)
730+
table.createIndex(int64, unique: true)
731731
)
732732
XCTAssertEqual(
733733
"CREATE INDEX IF NOT EXISTS \"index_table_on_int64\" ON \"table\" (\"int64\")",
734-
table.createIndex([int64], ifNotExists: true)
734+
table.createIndex(int64, ifNotExists: true)
735735
)
736736
XCTAssertEqual(
737737
"CREATE UNIQUE INDEX IF NOT EXISTS \"index_table_on_int64\" ON \"table\" (\"int64\")",
738-
table.createIndex([int64], unique: true, ifNotExists: true)
738+
table.createIndex(int64, unique: true, ifNotExists: true)
739739
)
740740
XCTAssertEqual(
741741
"CREATE UNIQUE INDEX IF NOT EXISTS \"main\".\"index_table_on_int64\" ON \"table\" (\"int64\")",
742-
qualifiedTable.createIndex([int64], unique: true, ifNotExists: true)
742+
qualifiedTable.createIndex(int64, unique: true, ifNotExists: true)
743743
)
744744
}
745745

746746
func test_dropIndex_compilesCreateIndexExpression() {
747747
XCTAssertEqual("DROP INDEX \"index_table_on_int64\"", table.dropIndex(int64))
748-
XCTAssertEqual("DROP INDEX IF EXISTS \"index_table_on_int64\"", table.dropIndex([int64], ifExists: true))
748+
XCTAssertEqual("DROP INDEX IF EXISTS \"index_table_on_int64\"", table.dropIndex(int64, ifExists: true))
749749
}
750750

751751
func test_create_onView_compilesCreateViewExpression() {

0 commit comments

Comments
 (0)