mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Resolve test issues with SQLCipher
Note: SQLCipher3 will have the new column rename method exposed, but it will throw an error at runtime if used.
This commit is contained in:
1 parent
09087bdbf9
commit
d14ac3e8d3
2 files changed
+16
-27
No files matched your search
@@ -687,7 +687,7 @@ public final class TableAlteration {
|
||||
return column
|
||||
}
|
||||
|
||||
#if GRDBCUSTOMSQLITE
|
||||
#if GRDBCUSTOMSQLITE || GRDBCipher
|
||||
/// Renames a column in a table.
|
||||
///
|
||||
/// try db.alter(table: "player") { t in
|
||||
@@ -699,9 +699,9 @@ public final class TableAlteration {
|
||||
/// - parameter name: the column name to rename.
|
||||
/// - parameter newName: the new name of the column.
|
||||
public func rename(column name: String, to newName: String) {
|
||||
alterations.append(.rename(old: name, new: newName))
|
||||
_rename(column: name, to: newName)
|
||||
}
|
||||
#elseif !os(OSX)
|
||||
#else
|
||||
/// Renames a column in a table.
|
||||
///
|
||||
/// try db.alter(table: "player") { t in
|
||||
@@ -714,9 +714,13 @@ public final class TableAlteration {
|
||||
/// - parameter newName: the new name of the column.
|
||||
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
public func rename(column name: String, to newName: String) {
|
||||
alterations.append(.rename(old: name, new: newName))
|
||||
_rename(column: name, to: newName)
|
||||
}
|
||||
#endif
|
||||
|
||||
private func _rename(column name: String, to newName: String) {
|
||||
alterations.append(.rename(old: name, new: newName))
|
||||
}
|
||||
|
||||
fileprivate func sql(_ db: Database) throws -> String {
|
||||
var statements: [String] = []
|
||||
|
||||
@@ -496,8 +496,15 @@ class TableDefinitionTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
#if GRDBCUSTOMSQLITE
|
||||
func testAlterTableRenameColumn() throws {
|
||||
guard sqlite3_libversion_number() >= 3025000 else {
|
||||
return
|
||||
}
|
||||
#if !GRDBCUSTOMSQLITE && !GRDBCIPHER
|
||||
guard #available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) else {
|
||||
return
|
||||
}
|
||||
#endif
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.create(table: "test") { t in
|
||||
@@ -516,28 +523,6 @@ class TableDefinitionTests: GRDBTestCase {
|
||||
assertEqualSQL(sqlQueries[sqlQueries.count - 1], "ALTER TABLE \"test\" RENAME COLUMN \"c\" TO \"d\"")
|
||||
}
|
||||
}
|
||||
#elseif !os(OSX)
|
||||
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *)
|
||||
func testAlterTableRenameColumn() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.create(table: "test") { t in
|
||||
t.column("a", .text)
|
||||
}
|
||||
|
||||
sqlQueries.removeAll()
|
||||
try db.alter(table: "test") { t in
|
||||
t.rename(column: "a", to: "b")
|
||||
t.add(column: "c")
|
||||
t.rename(column: "c", to: "d")
|
||||
}
|
||||
|
||||
assertEqualSQL(sqlQueries[sqlQueries.count - 3], "ALTER TABLE \"test\" RENAME COLUMN \"a\" TO \"b\"")
|
||||
assertEqualSQL(sqlQueries[sqlQueries.count - 2], "ALTER TABLE \"test\" ADD COLUMN \"c\"")
|
||||
assertEqualSQL(sqlQueries[sqlQueries.count - 1], "ALTER TABLE \"test\" RENAME COLUMN \"c\" TO \"d\"")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
func testDropTable() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
|
||||
Reference in new issue
Block a user