             // Nil is only possible for columns and scopes (optional
             // associations), not for prefetched rows.
             let row = decoder.row
-            return row[key.stringValue] == nil && (row.scopesTree[key.stringValue] == nil)
+            return row[column(forKey: key)] == nil && (row.scopesTree[key.stringValue] == nil)
         }
         
         // swiftlint:disable comma

            }
            
            // Scope? (beware left joins: check if scoped row contains non-null values)
            if let scopedRow = row.scopesTree[keyName], scopedRow.containsNonNullValue {
                return try decode(type, fromRow: scopedRow, codingPath: codingPath + [key])
            }
            

        
        func contains(_ key: Key) -> Bool {
            let row = decoder.row
            return row.hasColumn(column(forKey: key))
                || (row.scopesTree[key.stringValue] != nil)
                || (row.prefetchedRows[key.stringValue] != nil)
        }
