mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Fix failing tests for Database.indexes(on:) and Database.foreignKeys(on:)
This commit is contained in:
1 parent
60eb868fa5
commit
e915d28cb2
1 file changed
+16
@@ -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 }
|
||||
|
||||
Reference in new issue
Block a user