Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in optional support for decoding #1247

Closed
Chris-Stockbridge opened this issue Mar 5, 2024 · 1 comment
Closed

bug in optional support for decoding #1247

Chris-Stockbridge opened this issue Mar 5, 2024 · 1 comment

Comments

@Chris-Stockbridge
Copy link

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

@Chris-Stockbridge
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant