Fix failing tests for decodeNil()

Fix https://github.com/groue/GRDB.swift/issues/1531
This commit is contained in:
Gwendal Roué committed 2024-04-21 12:13:24 +02:00
1 parent de382d30b8
commit 7110a1fab3
1 file changed
+17 -7
+17 -7
View File
@@ -175,15 +175,25 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
func decodeNil(forKey key: Key) throws -> Bool {
let row = decoder.row
if let column = try? decodeColumn(forKey: key), row[column] != nil {
return false
}
if row.scopesTree[key.stringValue] != nil {
return false
}
if row.prefetchedRows[key.stringValue] != nil {
// Column?
if let column = try? decodeColumn(forKey: key),
let index = row.index(forColumn: column)
{
return row.hasNull(atIndex: index)
}
// Scope?
if let scopedRow = row.scopesTree[key.stringValue] {
return scopedRow.containsNonNullValue == false
}
// Prefetched Rows?
if let prefetchedRows = row.prefetchedRows[key.stringValue] {
return false
}
// Unknown key
return true
}