stephencelis/SQLite.swift

bug in optional support for decoding

Chris-Stockbridge opened this issue · 1 comments

If a table includes an optional custom struct, the decode method throws an error when the optional value is nil

I created a unit test demonstrating this here:
master...Chris-Stockbridge:SQLite.swift:master
d5b2adc

This unit test passes with the previous release, but breaks starting with 0.15.0

I think the issue comes from

guard let JSONString = try? row.get(Expression<String?>(key.stringValue)) else {

nil is a valid return value here. If row.get() throws, then this method should fail, but if the return value is nil then decodeIfPresent() should return nil.