Fix failing tests for Database.indexes(on:) and Database.foreignKeys(on:)

This commit is contained in:
Gwendal Roué committed 2018-06-05 14:38:59 +02:00
1 parent 60eb868fa5
commit e915d28cb2
1 file changed
+16
+16
View File
@@ -174,6 +174,14 @@ extension Database {
return IndexInfo(name: indexName, columns: columns, unique: unique)
}
if indexes.isEmpty {
// PRAGMA index_list doesn't throw any error when table does
// not exist. So let's check if table exists:
if try tableExists(tableName) == false {
throw DatabaseError(message: "no such table: \(tableName)")
}
}
schemaCache.set(indexes: indexes, forTable: tableName)
return indexes
}
@@ -208,6 +216,14 @@ extension Database {
}
}
if rawForeignKeys.isEmpty {
// PRAGMA foreign_key_list doesn't throw any error when table does
// not exist. So let's check if table exists:
if try tableExists(tableName) == false {
throw DatabaseError(message: "no such table: \(tableName)")
}
}
let foreignKeys = try rawForeignKeys.map { (destinationTable, columnMapping) -> ForeignKeyInfo in
let orderedMapping = columnMapping
.sorted { $0.seq < $1.seq }