Replace fetchCursor().next() with fetchOne()

This commit is contained in:
Gwendal Roué committed 2016-11-28 08:41:59 +01:00
1 parent cbf4ab797d
commit ee99abc266
4 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ public final class DatabasePool {
// Activate WAL Mode unless readonly
if !configuration.readonly {
try writer.sync { db in
let journalMode = try String.fetchCursor(db, "PRAGMA journal_mode = WAL").next()
let journalMode = try String.fetchOne(db, "PRAGMA journal_mode = WAL")
guard journalMode == "wal" else {
throw DatabaseError(message: "could not activate WAL Mode at path: \(path)")
}
+1 -1
View File
@@ -133,7 +133,7 @@
static func api(_ db: Database) -> UnsafePointer<fts5_api>? {
do {
return try Data.fetchCursor(db, "SELECT fts5()").next().flatMap { data in
return try Data.fetchOne(db, "SELECT fts5()").flatMap { data in
guard data.count == MemoryLayout<UnsafePointer<fts5_api>>.size else {
return nil
}
+2 -2
View File
@@ -39,7 +39,7 @@ struct Migration {
func run(_ db: Database) throws {
if #available(iOS 8.2, OSX 10.10, *) {
if try disabledForeignKeyChecks && (Bool.fetchCursor(db, "PRAGMA foreign_keys").next() ?? false) {
if try disabledForeignKeyChecks && (Bool.fetchOne(db, "PRAGMA foreign_keys") ?? false) {
try runWithDisabledForeignKeys(db)
} else {
try runWithoutDisabledForeignKeys(db)
@@ -75,7 +75,7 @@ struct Migration {
// > 10. If foreign key constraints were originally enabled then run PRAGMA
// > foreign_key_check to verify that the schema change did not break any foreign key
// > constraints.
if try Row.fetchCursor(db, "PRAGMA foreign_key_check").next() != nil {
if try Row.fetchOne(db, "PRAGMA foreign_key_check") != nil {
// https://www.sqlite.org/pragma.html#pragma_foreign_key_check
//
// PRAGMA foreign_key_check does not return an error,
+1 -1
View File
@@ -411,7 +411,7 @@ public extension MutablePersistable {
// Nil primary key
return false
}
return try Row.fetchCursor(statement).next() != nil
return try Row.fetchOne(statement) != nil
}
}