Skip to content

Commit

Permalink
Fix failing tests for decodeNil()
Browse files Browse the repository at this point in the history
Fix #1531
  • Loading branch information
groue committed Apr 21, 2024
1 parent de382d3 commit 7110a1f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions GRDB/Record/FetchableRecord+Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

// Column?
if let column = try? decodeColumn(forKey: key),
let index = row.index(forColumn: column)
{
return row.hasNull(atIndex: index)
}
if row.scopesTree[key.stringValue] != nil {
return false

// Scope?
if let scopedRow = row.scopesTree[key.stringValue] {
return scopedRow.containsNonNullValue == false
}
if row.prefetchedRows[key.stringValue] != nil {

// Prefetched Rows?
if let prefetchedRows = row.prefetchedRows[key.stringValue] {
return false
}

// Unknown key
return true
}

Expand Down

0 comments on commit 7110a1f

Please sign in to comment.