From e4a346995b88a589aeb2b2a98540c998fbc25805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 26 Feb 2017 17:24:44 +0100 Subject: [PATCH] #171: rename ResultCode.code into ResultCode.resultCode (@hartbit's suggestion) --- GRDB/Core/Database.swift | 22 ++++++------ GRDB/Core/DatabaseError.swift | 12 +++---- GRDB/Core/DatabasePool.swift | 2 +- GRDB/Core/DatabaseReader.swift | 8 ++--- GRDB/Core/DatabaseValueConvertible.swift | 6 ++-- GRDB/Core/RowAdapter.swift | 2 +- GRDB/Core/Statement.swift | 20 +++++------ GRDB/Core/StatementColumnConvertible.swift | 2 +- GRDB/FTS/FTS3Pattern.swift | 2 +- GRDB/FTS/FTS5CustomTokenizer.swift | 2 +- GRDB/FTS/FTS5Pattern.swift | 2 +- GRDB/FTS/FTS5Tokenizer.swift | 12 +++---- GRDB/FTS/FTS5WrapperTokenizer.swift | 2 +- GRDB/Migrations/Migration.swift | 2 +- GRDB/Record/RowConvertible.swift | 2 +- GRDB/Record/TableMapping.swift | 2 +- .../DatabasePoolSchemaCacheTests.swift | 2 +- .../DatabaseQueueSchemaCacheTests.swift | 2 +- Tests/Private/RecordUniqueIndexTests.swift | 8 ++--- .../Core/Database/ReadOnlyDatabaseTests.swift | 2 +- .../DatabaseCursor/DatabaseCursorTests.swift | 2 +- .../DatabasePoolConcurrencyTests.swift | 6 ++-- .../DatabaseQueueConcurrencyTests.swift | 6 ++-- .../DatabaseQueue/DatabaseQueueTests.swift | 6 ++-- .../DatabaseValueConvertibleFetchTests.swift | 36 +++++++++---------- .../Public/Core/Function/FunctionTests.swift | 12 +++---- .../Public/Core/Row/RowConvertibleTests.swift | 14 ++++---- Tests/Public/Core/Row/RowFetchTests.swift | 14 ++++---- .../Core/Savepoint/SavepointTests.swift | 4 +-- .../Core/Statement/SelectStatementTests.swift | 4 +-- .../Core/Statement/UpdateStatementTests.swift | 6 ++-- ...StatementColumnConvertibleFetchTests.swift | 28 +++++++-------- Tests/Public/Encryption/EncryptionTests.swift | 16 ++++----- .../FetchedRecordsControllerTests.swift | 2 +- .../VirtualTableModuleTests.swift | 4 +-- 35 files changed, 137 insertions(+), 137 deletions(-) diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 0fb33ab005..88e53525b5 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -311,7 +311,7 @@ public final class Database { var sqliteConnection: SQLiteConnection? = nil let code = sqlite3_open_v2(path, &sqliteConnection, configuration.SQLiteOpenFlags, nil) guard code == SQLITE_OK else { - throw DatabaseError(code: ResultCode(rawValue: code), message: String(cString: sqlite3_errmsg(sqliteConnection))) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: String(cString: sqlite3_errmsg(sqliteConnection))) } do { @@ -319,7 +319,7 @@ public final class Database { do { let code = sqlite3_extended_result_codes(sqliteConnection!, 1) guard code == SQLITE_OK else { - throw DatabaseError(code: ResultCode(rawValue: code), message: String(cString: sqlite3_errmsg(sqliteConnection))) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: String(cString: sqlite3_errmsg(sqliteConnection))) } } @@ -338,7 +338,7 @@ public final class Database { do { let code = sqlite3_exec(sqliteConnection, "SELECT * FROM sqlite_master LIMIT 1", nil, nil, nil) guard code == SQLITE_OK else { - throw DatabaseError(code: ResultCode(rawValue: code), message: String(cString: sqlite3_errmsg(sqliteConnection))) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: String(cString: sqlite3_errmsg(sqliteConnection))) } } } catch { @@ -664,7 +664,7 @@ extension Database { } let validateRemainingArguments = { if !arguments.values.isEmpty { - throw DatabaseError(code: .SQLITE_MISUSE, message: "wrong number of statement arguments: \(initialValuesCount)") + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "wrong number of statement arguments: \(initialValuesCount)") } } @@ -690,7 +690,7 @@ extension Database { var sqliteStatement: SQLiteStatement? = nil let code = sqlite3_prepare_v2(sqliteConnection, statementStart, -1, &sqliteStatement, &statementEnd) guard code == SQLITE_OK else { - error = DatabaseError(code: ResultCode(rawValue: code), message: lastErrorMessage, sql: sql) + error = DatabaseError(resultCode: ResultCode(rawValue: code), message: lastErrorMessage, sql: sql) break } @@ -779,7 +779,7 @@ extension Database { if let message = error.message { sqlite3_result_error(context, message, -1) } - sqlite3_result_error_code(context, error.code.rawValue) + sqlite3_result_error_code(context, error.resultCode.rawValue) } catch { sqlite3_result_error(context, "\(error)", -1) } @@ -787,7 +787,7 @@ extension Database { guard code == SQLITE_OK else { // Assume a GRDB bug: there is no point throwing any error. - fatalError(DatabaseError(code: ResultCode(rawValue: code), message: lastErrorMessage).description) + fatalError(DatabaseError(resultCode: ResultCode(rawValue: code), message: lastErrorMessage).description) } } @@ -802,7 +802,7 @@ extension Database { nil, nil, nil, nil, nil) guard code == SQLITE_OK else { // Assume a GRDB bug: there is no point throwing any error. - fatalError(DatabaseError(code: ResultCode(rawValue: code), message: lastErrorMessage).description) + fatalError(DatabaseError(resultCode: ResultCode(rawValue: code), message: lastErrorMessage).description) } } } @@ -891,7 +891,7 @@ extension Database { }, nil) guard code == SQLITE_OK else { // Assume a GRDB bug: there is no point throwing any error. - fatalError(DatabaseError(code: ResultCode(rawValue: code), message: lastErrorMessage).description) + fatalError(DatabaseError(resultCode: ResultCode(rawValue: code), message: lastErrorMessage).description) } } @@ -960,7 +960,7 @@ extension Database { sqlite3_key(sqliteConnection, bytes, Int32(data.count)) } guard code == SQLITE_OK else { - throw DatabaseError(code: code, message: String(cString: sqlite3_errmsg(sqliteConnection))) + throw DatabaseError(resultCode: code, message: String(cString: sqlite3_errmsg(sqliteConnection))) } } @@ -979,7 +979,7 @@ extension Database { sqlite3_rekey(sqliteConnection, bytes, Int32(data.count)) } guard code == SQLITE_OK else { - throw DatabaseError(code: code, message: String(cString: sqlite3_errmsg(sqliteConnection))) + throw DatabaseError(resultCode: code, message: String(cString: sqlite3_errmsg(sqliteConnection))) } } } diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index ba9c40d343..a359a9c81e 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -132,10 +132,10 @@ public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible public struct DatabaseError : Error { /// The SQLite error code (see https://www.sqlite.org/c3ref/c_abort.html). - public let code: ResultCode + public let resultCode: ResultCode public var primaryResultCode: ResultCode { - return code.primaryResultCode + return resultCode.primaryResultCode } /// The SQLite error message. @@ -144,8 +144,8 @@ public struct DatabaseError : Error { /// The SQL query that yielded the error (if relevant). public let sql: String? - public init(code: ResultCode = .SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) { - self.code = code + public init(resultCode: ResultCode = .SQLITE_ERROR, message: String? = nil, sql: String? = nil, arguments: StatementArguments? = nil) { + self.resultCode = resultCode self.message = message self.sql = sql self.arguments = arguments @@ -162,7 +162,7 @@ public struct DatabaseError : Error { extension DatabaseError: CustomStringConvertible { /// A textual representation of `self`. public var description: String { - var description = "SQLite error \(code.rawValue)" + var description = "SQLite error \(resultCode.rawValue)" if let sql = sql { description += " with statement `\(sql)`" } @@ -185,7 +185,7 @@ extension DatabaseError : CustomNSError { /// NSError bridging: the error code within the given domain. public var errorCode: Int { - return Int(code.rawValue) + return Int(resultCode.rawValue) } /// NSError bridging: the user-info dictionary. diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 818d4eccab..2fcd1c4413 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -133,7 +133,7 @@ public final class DatabasePool { // when kind is not .Passive. let code = sqlite3_wal_checkpoint_v2(db.sqliteConnection, nil, kind.rawValue, nil, nil) guard code == SQLITE_OK else { - throw DatabaseError(code: ResultCode(rawValue: code), message: db.lastErrorMessage, sql: nil) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: db.lastErrorMessage, sql: nil) } } } diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index 8c4521b221..cb2f5a3b9b 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -141,10 +141,10 @@ extension DatabaseReader { try read { dbFrom in try writer.write { dbDest in guard let backup = sqlite3_backup_init(dbDest.sqliteConnection, "main", dbFrom.sqliteConnection, "main") else { - throw DatabaseError(code: dbDest.lastErrorCode, message: dbDest.lastErrorMessage) + throw DatabaseError(resultCode: dbDest.lastErrorCode, message: dbDest.lastErrorMessage) } guard Int(bitPattern: backup) != Int(SQLITE_ERROR) else { - throw DatabaseError(code: .SQLITE_ERROR) + throw DatabaseError(resultCode: .SQLITE_ERROR) } afterBackupInit?() @@ -158,7 +158,7 @@ extension DatabaseReader { case SQLITE_OK: afterBackupStep?() case let code: - throw DatabaseError(code: ResultCode(rawValue: code), message: dbDest.lastErrorMessage) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: dbDest.lastErrorMessage) } } } catch { @@ -170,7 +170,7 @@ extension DatabaseReader { case SQLITE_OK: break case let code: - throw DatabaseError(code: ResultCode(rawValue: code), message: dbDest.lastErrorMessage) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: dbDest.lastErrorMessage) } dbDest.clearSchemaCache() diff --git a/GRDB/Core/DatabaseValueConvertible.swift b/GRDB/Core/DatabaseValueConvertible.swift index ed4fc48034..afd5a1ab68 100644 --- a/GRDB/Core/DatabaseValueConvertible.swift +++ b/GRDB/Core/DatabaseValueConvertible.swift @@ -121,7 +121,7 @@ extension DatabaseValueConvertible { if let value = Self.fromDatabaseValue(dbv) { return value } else { - throw DatabaseError(code: .SQLITE_ERROR, message: "could not convert database value \(dbv) to \(Self.self)", sql: statement.sql, arguments: arguments) + throw DatabaseError(resultCode: .SQLITE_ERROR, message: "could not convert database value \(dbv) to \(Self.self)", sql: statement.sql, arguments: arguments) } } } @@ -165,7 +165,7 @@ extension DatabaseValueConvertible { } else if dbv.isNull { return nil } else { - throw DatabaseError(code: .SQLITE_ERROR, message: "could not convert database value \(dbv) to \(Self.self)", sql: statement.sql, arguments: arguments) + throw DatabaseError(resultCode: .SQLITE_ERROR, message: "could not convert database value \(dbv) to \(Self.self)", sql: statement.sql, arguments: arguments) } } return try cursor.next() ?? nil @@ -336,7 +336,7 @@ extension Optional where Wrapped: DatabaseValueConvertible { } else if dbv.isNull { return nil } else { - throw DatabaseError(code: .SQLITE_ERROR, message: "could not convert database value \(dbv) to \(Wrapped.self)", sql: statement.sql, arguments: arguments) + throw DatabaseError(resultCode: .SQLITE_ERROR, message: "could not convert database value \(dbv) to \(Wrapped.self)", sql: statement.sql, arguments: arguments) } } } diff --git a/GRDB/Core/RowAdapter.swift b/GRDB/Core/RowAdapter.swift index 4f97c05968..571cf06c15 100644 --- a/GRDB/Core/RowAdapter.swift +++ b/GRDB/Core/RowAdapter.swift @@ -208,7 +208,7 @@ public struct ColumnMapping : RowAdapter { .map { (mappedColumn, baseColumn) -> (Int, String) in guard let index = layout.layoutIndex(ofColumn: baseColumn) else { let columnNames = layout.layoutColumns.map { $0.1 } - throw DatabaseError(code: .SQLITE_MISUSE, message: "Mapping references missing column \(baseColumn). Valid column names are: \(columnNames.joined(separator: ", ")).") + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "Mapping references missing column \(baseColumn). Valid column names are: \(columnNames.joined(separator: ", ")).") } let baseIndex = layout.layoutColumns[index].0 return (baseIndex, mappedColumn) diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 8f38ad1f93..d0aad47023 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -62,12 +62,12 @@ public class Statement { } guard code == SQLITE_OK else { - throw DatabaseError(code: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql) + throw DatabaseError(resultCode: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql) } guard remainingSQL.isEmpty else { sqlite3_finalize(sqliteStatement) - throw DatabaseError(code: .SQLITE_MISUSE, message: "Multiple statements found. To execute multiple statements, use Database.execute() instead.", sql: sql, arguments: nil) + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "Multiple statements found. To execute multiple statements, use Database.execute() instead.", sql: sql, arguments: nil) } self.database = database @@ -86,7 +86,7 @@ public class Statement { // throwing any error. let code = sqlite3_reset(sqliteStatement) guard code == SQLITE_OK else { - fatalError(DatabaseError(code: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql).description) + fatalError(DatabaseError(resultCode: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql).description) } } @@ -183,7 +183,7 @@ public class Statement { // It looks like sqlite3_bind_xxx() functions do not access the file system. // They should thus succeed, unless a GRDB bug: there is no point throwing any error. guard code == SQLITE_OK else { - fatalError(DatabaseError(code: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql).description) + fatalError(DatabaseError(resultCode: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql).description) } } @@ -194,7 +194,7 @@ public class Statement { // no point throwing any error. let code = sqlite3_clear_bindings(sqliteStatement) guard code == SQLITE_OK else { - fatalError(DatabaseError(code: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql).description) + fatalError(DatabaseError(resultCode: ResultCode(rawValue: code), message: database.lastErrorMessage, sql: sql).description) } } @@ -327,7 +327,7 @@ public final class DatabaseCursor : Cursor { return try element() case let errorCode: statement.database.selectStatementDidFail(statement) - throw DatabaseError(code: ResultCode(rawValue: errorCode), message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments) + throw DatabaseError(resultCode: ResultCode(rawValue: errorCode), message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments) } } } @@ -432,7 +432,7 @@ public final class UpdateStatement : Statement { // Let database rethrow eventual transaction observer error: try database.updateStatementDidFail(self) - throw DatabaseError(code: ResultCode(rawValue: errorCode), message: database.lastErrorMessage, sql: sql, arguments: self.arguments) // Error uses self.arguments, not the optional arguments parameter. + throw DatabaseError(resultCode: ResultCode(rawValue: errorCode), message: database.lastErrorMessage, sql: sql, arguments: self.arguments) // Error uses self.arguments, not the optional arguments parameter. } } } @@ -778,20 +778,20 @@ public struct StatementArguments { if let databaseValue = namedValues[argumentName] { return databaseValue } else if values.isEmpty { - throw DatabaseError(code: .SQLITE_MISUSE, message: "missing statement argument: \(argumentName)", sql: statement.sql, arguments: nil) + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "missing statement argument: \(argumentName)", sql: statement.sql, arguments: nil) } else { return values.removeFirst() } } else { if values.isEmpty { - throw DatabaseError(code: .SQLITE_MISUSE, message: "wrong number of statement arguments: \(initialValuesCount)", sql: statement.sql, arguments: nil) + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "wrong number of statement arguments: \(initialValuesCount)", sql: statement.sql, arguments: nil) } else { return values.removeFirst() } } } if !allowingRemainingValues && !values.isEmpty { - throw DatabaseError(code: .SQLITE_MISUSE, message: "wrong number of statement arguments: \(initialValuesCount)", sql: statement.sql, arguments: nil) + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "wrong number of statement arguments: \(initialValuesCount)", sql: statement.sql, arguments: nil) } return bindings } diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index d5497124e2..f669d62825 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -77,7 +77,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible { let sqliteStatement = statement.sqliteStatement return statement.fetchCursor(arguments: arguments) { if sqlite3_column_type(sqliteStatement, columnIndex) == SQLITE_NULL { - throw DatabaseError(code: .SQLITE_ERROR, message: "could not convert database value NULL to \(Self.self)", sql: statement.sql, arguments: arguments) + throw DatabaseError(resultCode: .SQLITE_ERROR, message: "could not convert database value NULL to \(Self.self)", sql: statement.sql, arguments: arguments) } return Self.init(sqliteStatement: sqliteStatement, index: columnIndex) } diff --git a/GRDB/FTS/FTS3Pattern.swift b/GRDB/FTS/FTS3Pattern.swift index f4421bf364..1f141aff9b 100644 --- a/GRDB/FTS/FTS3Pattern.swift +++ b/GRDB/FTS/FTS3Pattern.swift @@ -24,7 +24,7 @@ public struct FTS3Pattern { } } catch let error as DatabaseError { // Remove private SQL & arguments from the thrown error - throw DatabaseError(code: error.code, message: error.message, sql: nil, arguments: nil) + throw DatabaseError(resultCode: error.resultCode, message: error.message, sql: nil, arguments: nil) } // Pattern is valid diff --git a/GRDB/FTS/FTS5CustomTokenizer.swift b/GRDB/FTS/FTS5CustomTokenizer.swift index 083bbfa676..6635c7ed9f 100644 --- a/GRDB/FTS/FTS5CustomTokenizer.swift +++ b/GRDB/FTS/FTS5CustomTokenizer.swift @@ -134,7 +134,7 @@ } guard code == SQLITE_OK else { // Assume a GRDB bug: there is no point throwing any error. - fatalError(DatabaseError(code: code, message: lastErrorMessage).description) + fatalError(DatabaseError(resultCode: code, message: lastErrorMessage).description) } } } diff --git a/GRDB/FTS/FTS5Pattern.swift b/GRDB/FTS/FTS5Pattern.swift index 36fd7bc6b3..c3e77a1d6a 100644 --- a/GRDB/FTS/FTS5Pattern.swift +++ b/GRDB/FTS/FTS5Pattern.swift @@ -67,7 +67,7 @@ } } catch let error as DatabaseError { // Remove private SQL & arguments from the thrown error - throw DatabaseError(code: error.code, message: error.message, sql: nil, arguments: nil) + throw DatabaseError(resultCode: error.code, message: error.message, sql: nil, arguments: nil) } // Pattern is valid diff --git a/GRDB/FTS/FTS5Tokenizer.swift b/GRDB/FTS/FTS5Tokenizer.swift index fc153138ff..50207ad94f 100644 --- a/GRDB/FTS/FTS5Tokenizer.swift +++ b/GRDB/FTS/FTS5Tokenizer.swift @@ -87,7 +87,7 @@ return SQLITE_OK }) if (code != SQLITE_OK) { - throw DatabaseError(code: code) + throw DatabaseError(resultCode: code) } } return context.tokens @@ -116,7 +116,7 @@ init(xTokenizer: fts5_tokenizer, contextPointer: UnsafeMutableRawPointer?, arguments: [String]) throws { guard let xCreate = xTokenizer.xCreate else { - throw DatabaseError(code: .SQLITE_ERROR, message: "nil fts5_tokenizer.xCreate") + throw DatabaseError(resultCode: .SQLITE_ERROR, message: "nil fts5_tokenizer.xCreate") } self.xTokenizer = xTokenizer @@ -147,13 +147,13 @@ } guard code == SQLITE_OK else { - throw DatabaseError(code: code, message: "failed fts5_tokenizer.xCreate") + throw DatabaseError(resultCode: code, message: "failed fts5_tokenizer.xCreate") } if let tokenizerPointer = tokenizerPointer { self.tokenizerPointer = tokenizerPointer } else { - throw DatabaseError(code: code, message: "nil tokenizer") + throw DatabaseError(resultCode: code, message: "nil tokenizer") } } @@ -189,7 +189,7 @@ /// } public func makeTokenizer(_ descriptor: FTS5TokenizerDescriptor) throws -> FTS5Tokenizer { guard let api = FTS5.api(self) else { - throw DatabaseError(code: .SQLITE_MISUSE, message: "FTS5 API not found") + throw DatabaseError(resultCode: .SQLITE_MISUSE, message: "FTS5 API not found") } let xTokenizerPointer: UnsafeMutablePointer = .allocate(capacity: 1) @@ -205,7 +205,7 @@ xTokenizerPointer) guard code == SQLITE_OK else { - throw DatabaseError(code: code) + throw DatabaseError(resultCode: code) } let contextPointer = contextHandle.pointee diff --git a/GRDB/FTS/FTS5WrapperTokenizer.swift b/GRDB/FTS/FTS5WrapperTokenizer.swift index b237200b54..709b7d6aa6 100644 --- a/GRDB/FTS/FTS5WrapperTokenizer.swift +++ b/GRDB/FTS/FTS5WrapperTokenizer.swift @@ -123,7 +123,7 @@ // Inject token bytes into SQLite let code = tokenCallback(context, flags.rawValue, pToken, nToken, iStart, iEnd) guard code == SQLITE_OK else { - throw DatabaseError(code: code, message: "token callback failed") + throw DatabaseError(resultCode: code, message: "token callback failed") } } }) diff --git a/GRDB/Migrations/Migration.swift b/GRDB/Migrations/Migration.swift index bb5b53cfcb..2077bbb2d4 100644 --- a/GRDB/Migrations/Migration.swift +++ b/GRDB/Migrations/Migration.swift @@ -86,7 +86,7 @@ struct Migration { // // Let's turn any violation into an SQLITE_CONSTRAINT // error, and rollback the transaction. - throw DatabaseError(code: .SQLITE_CONSTRAINT, message: "FOREIGN KEY constraint failed") + throw DatabaseError(resultCode: .SQLITE_CONSTRAINT, message: "FOREIGN KEY constraint failed") } // > 11. Commit the transaction started in step 2. diff --git a/GRDB/Record/RowConvertible.swift b/GRDB/Record/RowConvertible.swift index 499af35601..0e702dc99e 100644 --- a/GRDB/Record/RowConvertible.swift +++ b/GRDB/Record/RowConvertible.swift @@ -454,7 +454,7 @@ extension RowConvertible where Self: TableMapping { GRDBPrecondition(dictionary.count > 0, "Invalid empty key dictionary") let columns = Array(dictionary.keys) guard let orderedColumns = try db.columnsForUniqueKey(columns, in: databaseTableName) else { - let error = DatabaseError(code: .SQLITE_MISUSE, message: "table \(databaseTableName) has no unique index on column(s) \(columns.sorted().joined(separator: ", "))") + let error = DatabaseError(resultCode: .SQLITE_MISUSE, message: "table \(databaseTableName) has no unique index on column(s) \(columns.sorted().joined(separator: ", "))") if fatalErrorOnMissingUniqueIndex { // Programmer error fatalError(error.description) diff --git a/GRDB/Record/TableMapping.swift b/GRDB/Record/TableMapping.swift index b52ea70385..518f3dfb07 100644 --- a/GRDB/Record/TableMapping.swift +++ b/GRDB/Record/TableMapping.swift @@ -206,7 +206,7 @@ extension TableMapping { GRDBPrecondition(dictionary.count > 0, "Invalid empty key dictionary") let columns = Array(dictionary.keys) guard let orderedColumns = try db.columnsForUniqueKey(columns, in: databaseTableName) else { - let error = DatabaseError(code: .SQLITE_MISUSE, message: "table \(databaseTableName) has no unique index on column(s) \(columns.sorted().joined(separator: ", "))") + let error = DatabaseError(resultCode: .SQLITE_MISUSE, message: "table \(databaseTableName) has no unique index on column(s) \(columns.sorted().joined(separator: ", "))") if fatalErrorOnMissingUniqueIndex { fatalError(error.description) } else { diff --git a/Tests/Private/DatabasePoolSchemaCacheTests.swift b/Tests/Private/DatabasePoolSchemaCacheTests.swift index 3e46cfc4fb..2da931aa12 100644 --- a/Tests/Private/DatabasePoolSchemaCacheTests.swift +++ b/Tests/Private/DatabasePoolSchemaCacheTests.swift @@ -95,7 +95,7 @@ class DatabasePoolSchemaCacheTests : GRDBTestCase { _ = try db.primaryKey("items") XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!, "no such table: items") XCTAssertEqual(error.description, "SQLite error 1: no such table: items") } diff --git a/Tests/Private/DatabaseQueueSchemaCacheTests.swift b/Tests/Private/DatabaseQueueSchemaCacheTests.swift index 9971dc16ba..3bbceb3b77 100644 --- a/Tests/Private/DatabaseQueueSchemaCacheTests.swift +++ b/Tests/Private/DatabaseQueueSchemaCacheTests.swift @@ -46,7 +46,7 @@ class DatabaseQueueSchemaCacheTests : GRDBTestCase { _ = try db.primaryKey("items") XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!, "no such table: items") XCTAssertEqual(error.description, "SQLite error 1: no such table: items") } diff --git a/Tests/Private/RecordUniqueIndexTests.swift b/Tests/Private/RecordUniqueIndexTests.swift index 525cc844df..0eadbc13c6 100644 --- a/Tests/Private/RecordUniqueIndexTests.swift +++ b/Tests/Private/RecordUniqueIndexTests.swift @@ -27,7 +27,7 @@ class RecordUniqueIndexTests: GRDBTestCase { _ = try Person.makeFetchByKeyStatement(db, keys: [["id": nil, "email": nil]], fatalErrorOnMissingUniqueIndex: false) XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message!, "table persons has no unique index on column(s) email, id") XCTAssertEqual(error.description, "SQLite error 21: table persons has no unique index on column(s) email, id") } @@ -35,7 +35,7 @@ class RecordUniqueIndexTests: GRDBTestCase { _ = try Person.makeFetchByKeyStatement(db, keys: [["name": nil]], fatalErrorOnMissingUniqueIndex: false) XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message!, "table persons has no unique index on column(s) name") XCTAssertEqual(error.description, "SQLite error 21: table persons has no unique index on column(s) name") } @@ -55,7 +55,7 @@ class RecordUniqueIndexTests: GRDBTestCase { _ = try Person.makeDeleteByKeyStatement(db, keys: [["id": nil, "email": nil]], fatalErrorOnMissingUniqueIndex: false) XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message!, "table persons has no unique index on column(s) email, id") XCTAssertEqual(error.description, "SQLite error 21: table persons has no unique index on column(s) email, id") } @@ -63,7 +63,7 @@ class RecordUniqueIndexTests: GRDBTestCase { _ = try Person.makeDeleteByKeyStatement(db, keys: [["name": nil]], fatalErrorOnMissingUniqueIndex: false) XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message!, "table persons has no unique index on column(s) name") XCTAssertEqual(error.description, "SQLite error 21: table persons has no unique index on column(s) name") } diff --git a/Tests/Public/Core/Database/ReadOnlyDatabaseTests.swift b/Tests/Public/Core/Database/ReadOnlyDatabaseTests.swift index c75d649aba..2aee1e09a8 100644 --- a/Tests/Public/Core/Database/ReadOnlyDatabaseTests.swift +++ b/Tests/Public/Core/Database/ReadOnlyDatabaseTests.swift @@ -28,7 +28,7 @@ class ReadOnlyDatabaseTests : GRDBTestCase { } XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_READONLY) + XCTAssertEqual(error.resultCode, .SQLITE_READONLY) XCTAssertEqual(error.message!, "attempt to write a readonly database") XCTAssertEqual(error.sql!, "CREATE TABLE items (id INTEGER PRIMARY KEY)") XCTAssertEqual(error.description, "SQLite error 8 with statement `CREATE TABLE items (id INTEGER PRIMARY KEY)`: attempt to write a readonly database") diff --git a/Tests/Public/Core/DatabaseCursor/DatabaseCursorTests.swift b/Tests/Public/Core/DatabaseCursor/DatabaseCursorTests.swift index 25b3e190cb..b8976488f4 100644 --- a/Tests/Public/Core/DatabaseCursor/DatabaseCursorTests.swift +++ b/Tests/Public/Core/DatabaseCursor/DatabaseCursorTests.swift @@ -47,7 +47,7 @@ class DatabaseCursorTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, "SELECT 1 UNION ALL SELECT throw()") XCTAssertEqual(error.description, "SQLite error 1 with statement `SELECT 1 UNION ALL SELECT throw()`: \(customError)") diff --git a/Tests/Public/Core/DatabasePool/DatabasePoolConcurrencyTests.swift b/Tests/Public/Core/DatabasePool/DatabasePoolConcurrencyTests.swift index 707754cfa3..64a1ce587e 100644 --- a/Tests/Public/Core/DatabasePool/DatabasePoolConcurrencyTests.swift +++ b/Tests/Public/Core/DatabasePool/DatabasePoolConcurrencyTests.swift @@ -248,7 +248,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { try db.execute("BEGIN DEFERRED TRANSACTION") XCTFail("Expected error") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!, "cannot start a transaction within a transaction") XCTAssertEqual(error.sql!, "BEGIN DEFERRED TRANSACTION") XCTAssertEqual(error.description, "SQLite error 1 with statement `BEGIN DEFERRED TRANSACTION`: cannot start a transaction within a transaction") @@ -281,7 +281,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { try dbPool.read { _ in } XCTFail("Expected error") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_BUSY) + XCTAssertEqual(error.resultCode, .SQLITE_BUSY) XCTAssertEqual(error.message!, "database is locked") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 5: database is locked") @@ -897,7 +897,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase { } XCTFail("Expected error") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_BUSY) + XCTAssertEqual(error.resultCode, .SQLITE_BUSY) XCTAssertEqual(error.message!, "database is locked") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 5: database is locked") diff --git a/Tests/Public/Core/DatabaseQueue/DatabaseQueueConcurrencyTests.swift b/Tests/Public/Core/DatabaseQueue/DatabaseQueueConcurrencyTests.swift index 744fd381e0..30a49df920 100644 --- a/Tests/Public/Core/DatabaseQueue/DatabaseQueueConcurrencyTests.swift +++ b/Tests/Public/Core/DatabaseQueue/DatabaseQueueConcurrencyTests.swift @@ -113,7 +113,7 @@ class ConcurrencyTests: GRDBTestCase { _ = group.wait(timeout: .distantFuture) if let concurrencyError = concurrencyError { - XCTAssertEqual(concurrencyError.code, .SQLITE_BUSY) + XCTAssertEqual(concurrencyError.resultCode, .SQLITE_BUSY) XCTAssertEqual(concurrencyError.sql, "INSERT INTO stuffs (id) VALUES (NULL)") } else { XCTFail("Expected concurrency error") @@ -171,7 +171,7 @@ class ConcurrencyTests: GRDBTestCase { _ = group.wait(timeout: .distantFuture) if let concurrencyError = concurrencyError { - XCTAssertEqual(concurrencyError.code, .SQLITE_BUSY) + XCTAssertEqual(concurrencyError.resultCode, .SQLITE_BUSY) XCTAssertEqual(concurrencyError.sql, "BEGIN EXCLUSIVE TRANSACTION") } else { XCTFail("Expected concurrency error") @@ -229,7 +229,7 @@ class ConcurrencyTests: GRDBTestCase { _ = group.wait(timeout: .distantFuture) if let concurrencyError = concurrencyError { - XCTAssertEqual(concurrencyError.code, .SQLITE_BUSY) + XCTAssertEqual(concurrencyError.resultCode, .SQLITE_BUSY) XCTAssertEqual(concurrencyError.sql, "BEGIN IMMEDIATE TRANSACTION") } else { XCTFail("Expected concurrency error") diff --git a/Tests/Public/Core/DatabaseQueue/DatabaseQueueTests.swift b/Tests/Public/Core/DatabaseQueue/DatabaseQueueTests.swift index df3f12eef5..bf4c3de070 100644 --- a/Tests/Public/Core/DatabaseQueue/DatabaseQueueTests.swift +++ b/Tests/Public/Core/DatabaseQueue/DatabaseQueueTests.swift @@ -21,7 +21,7 @@ class DatabaseQueueTests: GRDBTestCase { _ = try DatabaseQueue(path: url.path) XCTFail("Expected error") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!.lowercased(), "file is encrypted or is not a database") // lowercased: accept multiple SQLite version XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description.lowercased(), "sqlite error 26: file is encrypted or is not a database") @@ -55,7 +55,7 @@ class DatabaseQueueTests: GRDBTestCase { } catch let error as DatabaseError { // expected error - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!.lowercased(), "no such function: succ") // lowercaseString: accept multiple SQLite version XCTAssertEqual(error.sql!, "SELECT succ(1)") XCTAssertEqual(error.description.lowercased(), "sqlite error 1 with statement `select succ(1)`: no such function: succ") @@ -86,7 +86,7 @@ class DatabaseQueueTests: GRDBTestCase { } catch let error as DatabaseError { // expected error - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!.lowercased(), "no such collation sequence: test_collation_foo") // lowercaseString: accept multiple SQLite version XCTAssertEqual(error.sql!, "CREATE TABLE files_fail (name TEXT COLLATE TEST_COLLATION_FOO)") XCTAssertEqual(error.description.lowercased(), "sqlite error 1 with statement `create table files_fail (name text collate test_collation_foo)`: no such collation sequence: test_collation_foo") diff --git a/Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConvertibleFetchTests.swift b/Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConvertibleFetchTests.swift index 8b3789cd6f..b9fe919121 100644 --- a/Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConvertibleFetchTests.swift +++ b/Tests/Public/Core/DatabaseValueConvertible/DatabaseValueConvertibleFetchTests.swift @@ -68,7 +68,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value NULL to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value NULL to \(Fetched.self)") @@ -77,7 +77,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value \"foo\" to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value \"foo\" to \(Fetched.self)") @@ -118,7 +118,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -127,7 +127,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 21 with statement `\(sql)`: \(customError)") @@ -161,7 +161,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -223,7 +223,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value NULL to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value NULL to \(Fetched.self)") @@ -261,7 +261,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -295,7 +295,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -403,7 +403,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value \"foo\" to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value \"foo\" to \(Fetched.self)") @@ -441,7 +441,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -475,7 +475,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -543,7 +543,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value \"foo\" to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value \"foo\" to \(Fetched.self)") @@ -584,7 +584,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -593,7 +593,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 21 with statement `\(sql)`: \(customError)") @@ -627,7 +627,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try cursor() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -691,7 +691,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value \"foo\" to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value \"foo\" to \(Fetched.self)") @@ -729,7 +729,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -763,7 +763,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") diff --git a/Tests/Public/Core/Function/FunctionTests.swift b/Tests/Public/Core/Function/FunctionTests.swift index 38c340f339..9cab2655ac 100644 --- a/Tests/Public/Core/Function/FunctionTests.swift +++ b/Tests/Public/Core/Function/FunctionTests.swift @@ -305,7 +305,7 @@ class FunctionTests: GRDBTestCase { try db.execute("INSERT INTO items VALUES (f(1))") XCTFail("Expected DatabaseError") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "custom error message") } } @@ -316,7 +316,7 @@ class FunctionTests: GRDBTestCase { assertNoError { let dbQueue = try makeDatabaseQueue() let fn = DatabaseFunction("f", argumentCount: 1) { databaseValues in - throw DatabaseError(code: ResultCode(rawValue: 123)) + throw DatabaseError(resultCode: ResultCode(rawValue: 123)) } dbQueue.add(function: fn) try dbQueue.inDatabase { db in @@ -325,7 +325,7 @@ class FunctionTests: GRDBTestCase { try db.execute("INSERT INTO items VALUES (f(1))") XCTFail("Expected DatabaseError") } catch let error as DatabaseError { - XCTAssertEqual(error.code.rawValue, 123) + XCTAssertEqual(error.resultCode.rawValue, 123) XCTAssertEqual(error.message, "unknown error") } } @@ -336,7 +336,7 @@ class FunctionTests: GRDBTestCase { assertNoError { let dbQueue = try makeDatabaseQueue() let fn = DatabaseFunction("f", argumentCount: 1) { databaseValues in - throw DatabaseError(code: ResultCode(rawValue: 123), message: "custom error message") + throw DatabaseError(resultCode: ResultCode(rawValue: 123), message: "custom error message") } dbQueue.add(function: fn) try dbQueue.inDatabase { db in @@ -345,7 +345,7 @@ class FunctionTests: GRDBTestCase { try db.execute("INSERT INTO items VALUES (f(1))") XCTFail("Expected DatabaseError") } catch let error as DatabaseError { - XCTAssertEqual(error.code.rawValue, 123) + XCTAssertEqual(error.resultCode.rawValue, 123) XCTAssertEqual(error.message, "custom error message") } } @@ -365,7 +365,7 @@ class FunctionTests: GRDBTestCase { try db.execute("INSERT INTO items VALUES (f(1))") XCTFail("Expected DatabaseError") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertTrue(error.message!.contains("CustomErrorDomain")) XCTAssertTrue(error.message!.contains("123")) XCTAssertTrue(error.message!.contains("custom error message")) diff --git a/Tests/Public/Core/Row/RowConvertibleTests.swift b/Tests/Public/Core/Row/RowConvertibleTests.swift index 5d038eaf0a..3301a36455 100644 --- a/Tests/Public/Core/Row/RowConvertibleTests.swift +++ b/Tests/Public/Core/Row/RowConvertibleTests.swift @@ -86,7 +86,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -95,7 +95,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 21 with statement `\(sql)`: \(customError)") @@ -129,7 +129,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try cursor() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -195,7 +195,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -229,7 +229,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -319,7 +319,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -353,7 +353,7 @@ class RowConvertibleTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") diff --git a/Tests/Public/Core/Row/RowFetchTests.swift b/Tests/Public/Core/Row/RowFetchTests.swift index e23e3cc987..3a8d0d1d92 100644 --- a/Tests/Public/Core/Row/RowFetchTests.swift +++ b/Tests/Public/Core/Row/RowFetchTests.swift @@ -57,7 +57,7 @@ class RowFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -66,7 +66,7 @@ class RowFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 21 with statement `\(sql)`: \(customError)") @@ -100,7 +100,7 @@ class RowFetchTests: GRDBTestCase { _ = try cursor() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -165,7 +165,7 @@ class RowFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -199,7 +199,7 @@ class RowFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -288,7 +288,7 @@ class RowFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -322,7 +322,7 @@ class RowFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") diff --git a/Tests/Public/Core/Savepoint/SavepointTests.swift b/Tests/Public/Core/Savepoint/SavepointTests.swift index 3e32835705..ad1947f281 100644 --- a/Tests/Public/Core/Savepoint/SavepointTests.swift +++ b/Tests/Public/Core/Savepoint/SavepointTests.swift @@ -592,11 +592,11 @@ class SavepointTests: GRDBTestCase { do { try db.inSavepoint { try insertItem(db, name: "item1") - throw DatabaseError(code: ResultCode(rawValue: 123)) + throw DatabaseError(resultCode: ResultCode(rawValue: 123)) } XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code.rawValue, 123) + XCTAssertEqual(error.resultCode.rawValue, 123) } try db.inSavepoint { diff --git a/Tests/Public/Core/Statement/SelectStatementTests.swift b/Tests/Public/Core/Statement/SelectStatementTests.swift index 51778e0a3f..ffe8a57c16 100644 --- a/Tests/Public/Core/Statement/SelectStatementTests.swift +++ b/Tests/Public/Core/Statement/SelectStatementTests.swift @@ -95,7 +95,7 @@ class SelectStatementTests : GRDBTestCase { _ = try db.makeSelectStatement("SELECT * FROM blah") XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!, "no such table: blah") XCTAssertEqual(error.sql!, "SELECT * FROM blah") XCTAssertEqual(error.description, "SQLite error 1 with statement `SELECT * FROM blah`: no such table: blah") @@ -125,7 +125,7 @@ class SelectStatementTests : GRDBTestCase { _ = try String.fetchAll(db.cachedSelectStatement(sql)) XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!, "boom") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: boom") diff --git a/Tests/Public/Core/Statement/UpdateStatementTests.swift b/Tests/Public/Core/Statement/UpdateStatementTests.swift index 1cf488a355..190e5ae5da 100644 --- a/Tests/Public/Core/Statement/UpdateStatementTests.swift +++ b/Tests/Public/Core/Statement/UpdateStatementTests.swift @@ -293,7 +293,7 @@ class UpdateStatementTests : GRDBTestCase { _ = try db.makeUpdateStatement("UPDATE blah SET id = 12") XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message!, "no such table: blah") XCTAssertEqual(error.sql!, "UPDATE blah SET id = 12") XCTAssertEqual(error.description, "SQLite error 1 with statement `UPDATE blah SET id = 12`: no such table: blah") @@ -310,7 +310,7 @@ class UpdateStatementTests : GRDBTestCase { _ = try db.makeUpdateStatement("UPDATE persons SET age = 1; UPDATE persons SET age = 2;") XCTFail("Expected error") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message!, "Multiple statements found. To execute multiple statements, use Database.execute() instead.") XCTAssertEqual(error.sql!, "UPDATE persons SET age = 1; UPDATE persons SET age = 2;") XCTAssertEqual(error.description, "SQLite error 21 with statement `UPDATE persons SET age = 1; UPDATE persons SET age = 2;`: Multiple statements found. To execute multiple statements, use Database.execute() instead.") @@ -327,7 +327,7 @@ class UpdateStatementTests : GRDBTestCase { _ = try db.makeUpdateStatement("UPDATE persons SET age = 1;x") XCTFail("Expected error") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message!, "Multiple statements found. To execute multiple statements, use Database.execute() instead.") XCTAssertEqual(error.sql!, "UPDATE persons SET age = 1;x") XCTAssertEqual(error.description, "SQLite error 21 with statement `UPDATE persons SET age = 1;x`: Multiple statements found. To execute multiple statements, use Database.execute() instead.") diff --git a/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift b/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift index 5c1c48993e..11bdf72498 100644 --- a/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift +++ b/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift @@ -144,7 +144,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value NULL to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value NULL to \(Fetched.self)") @@ -190,7 +190,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -199,7 +199,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_MISUSE) + XCTAssertEqual(error.resultCode, .SQLITE_MISUSE) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 21 with statement `\(sql)`: \(customError)") @@ -233,7 +233,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try cursor() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -296,7 +296,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value NULL to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value NULL to \(Fetched.self)") @@ -334,7 +334,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -368,7 +368,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -478,7 +478,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -512,7 +512,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try value() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -586,7 +586,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try cursor.next() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value \"foo\" to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value \"foo\" to \(Fetched.self)") @@ -625,7 +625,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try cursor() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") @@ -693,7 +693,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "could not convert database value \"foo\" to \(Fetched.self)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: could not convert database value \"foo\" to \(Fetched.self)") @@ -731,7 +731,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "\(customError)") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: \(customError)") @@ -765,7 +765,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { _ = try array() XCTFail() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: nonExistingTable") XCTAssertEqual(error.sql!, sql) XCTAssertEqual(error.description, "SQLite error 1 with statement `\(sql)`: no such table: nonExistingTable") diff --git a/Tests/Public/Encryption/EncryptionTests.swift b/Tests/Public/Encryption/EncryptionTests.swift index a25b85742c..e60d74ac31 100644 --- a/Tests/Public/Encryption/EncryptionTests.swift +++ b/Tests/Public/Encryption/EncryptionTests.swift @@ -40,7 +40,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabaseQueue() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -66,7 +66,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabaseQueue() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -146,7 +146,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabasePool() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -171,7 +171,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabasePool() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -248,7 +248,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabasePool() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -273,7 +273,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabasePool() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -353,7 +353,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabaseQueue() } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") @@ -377,7 +377,7 @@ class EncryptionTests: GRDBTestCase { do { _ = try makeDatabaseQueue(filename: "plaintext.sqlite") } catch let error as DatabaseError { - XCTAssertEqual(error.code, .SQLITE_NOTADB) + XCTAssertEqual(error.resultCode, .SQLITE_NOTADB) XCTAssertEqual(error.message!, "file is encrypted or is not a database") XCTAssertTrue(error.sql == nil) XCTAssertEqual(error.description, "SQLite error 26: file is encrypted or is not a database") diff --git a/Tests/Public/FetchedRecordsController/FetchedRecordsControllerTests.swift b/Tests/Public/FetchedRecordsController/FetchedRecordsControllerTests.swift index 12ee249d6f..ccfe59c978 100644 --- a/Tests/Public/FetchedRecordsController/FetchedRecordsControllerTests.swift +++ b/Tests/Public/FetchedRecordsController/FetchedRecordsControllerTests.swift @@ -892,7 +892,7 @@ class FetchedRecordsControllerTests: GRDBTestCase { } waitForExpectations(timeout: 1, handler: nil) if let error = error as? DatabaseError { - XCTAssertEqual(error.code, .SQLITE_ERROR) + XCTAssertEqual(error.resultCode, .SQLITE_ERROR) XCTAssertEqual(error.message, "no such table: persons") XCTAssertEqual(error.sql!, "SELECT * FROM \"persons\"") XCTAssertEqual(error.description, "SQLite error 1 with statement `SELECT * FROM \"persons\"`: no such table: persons") diff --git a/Tests/Public/SQLTableBuilder/VirtualTableModuleTests.swift b/Tests/Public/SQLTableBuilder/VirtualTableModuleTests.swift index 23106b4aef..6efb072386 100644 --- a/Tests/Public/SQLTableBuilder/VirtualTableModuleTests.swift +++ b/Tests/Public/SQLTableBuilder/VirtualTableModuleTests.swift @@ -40,7 +40,7 @@ private struct ThrowingFTS3TokenizeModule : VirtualTableModule { } func database(_ db: Database, didCreate tableName: String, using definition: FTS3TokenizeTableDefinition) throws { - throw DatabaseError(code: ResultCode(rawValue: 123)) + throw DatabaseError(resultCode: ResultCode(rawValue: 123)) } } @@ -73,7 +73,7 @@ class VirtualTableModuleTests: GRDBTestCase { } XCTFail("Expected DatabaseError") } catch let error as DatabaseError { - XCTAssertEqual(error.code.rawValue, 123) + XCTAssertEqual(error.resultCode.rawValue, 123) } assertDidExecute(sql: "CREATE VIRTUAL TABLE \"test\" USING fts3tokenize(simple)") XCTAssertFalse(try db.tableExists("test"))