Skip to content

Commit 7b269da

Browse files
committed
Update SQLiteAdapter.swift
1 parent 74833fd commit 7b269da

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

Sources/SQLiteAdapter/SQLiteAdapter.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public protocol SQLiteType {
4949
func createTable(sql: String) throws
5050
func checkIfTableExists(_ tableName: String) throws -> Bool
5151
func dropTable(_ tableName: String, vacuum: Bool) throws
52-
func deleteAllRows(in tableName: String, vacuum: Bool, resetAutoincrement: Bool) throws
5352
func addIndex(to tableName: String, forColumn columnName: String, unique: Bool, order: SQLOrder) throws
5453
func checkIfIndexExists(in tableName: String, indexName: String) throws -> Bool
5554
func dropIndex(in tableName: String, forColumn columnName: String) throws
@@ -59,6 +58,7 @@ public protocol SQLiteType {
5958
func updateRow(sql: String, valuesToBind: SQLValues?) throws
6059
func deleteRow(sql: String, valuesToBind: SQLValues?) throws
6160
func deleteByID(in tableName: String, id: Int) throws
61+
func deleteAllRows(in tableName: String, vacuum: Bool, resetAutoincrement: Bool) throws
6262
func getRowCount(in tableName: String) throws -> Int
6363
func getRowCountWithCondition(sql: String, valuesToBind: SQLValues?) throws -> Int
6464
func getRow(sql: String, valuesToBind: SQLValues?, valuesToGet: SQLValues) throws -> [SQLValues]
@@ -235,18 +235,6 @@ open class SQLite: SQLiteType {
235235
log("successfully droped table \(tableName)")
236236
}
237237

238-
public func deleteAllRows(in tableName: String, vacuum: Bool = true, resetAutoincrement: Bool = true) throws {
239-
let sql = "DELETE FROM \(tableName);"
240-
try operation(sql: sql)
241-
if vacuum {
242-
try self.vacuum()
243-
}
244-
log("successfully deleted all rows in \(tableName)")
245-
if resetAutoincrement {
246-
try self.resetAutoincrement(in: tableName)
247-
}
248-
}
249-
250238
public func addIndex(to tableName: String, forColumn columnName: String, unique: Bool = false, order: SQLOrder = .none) throws {
251239

252240
let indexName = "\(tableName)_\(columnName)_idx"
@@ -324,6 +312,18 @@ open class SQLite: SQLiteType {
324312
log("successfully deleted a row by id \(id) in \(tableName)")
325313
}
326314

315+
public func deleteAllRows(in tableName: String, vacuum: Bool = true, resetAutoincrement: Bool = true) throws {
316+
let sql = "DELETE FROM \(tableName);"
317+
try operation(sql: sql)
318+
if vacuum {
319+
try self.vacuum()
320+
}
321+
log("successfully deleted all rows in \(tableName)")
322+
if resetAutoincrement {
323+
try self.resetAutoincrement(in: tableName)
324+
}
325+
}
326+
327327
public func getRowCount(in tableName: String) throws -> Int {
328328
let sql = "SELECT COUNT(*) FROM \(tableName);"
329329
let sqlStatement = try prepareStatement(sql: sql)

0 commit comments

Comments
 (0)