stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.72k stars 1.57k forks source link

Add optional support for decoding #1224

Closed JacobHearst closed 1 year ago

JacobHearst commented 1 year ago

Closes #997 by adding support for optional types when decoding a row.

JacobHearst commented 1 year ago

The test_insert_encodable_with_nested_encodable() test is failing although truthfully I'm not sure how it ever passed since it seems to relies on the order of keys in a dictionary. Am I missing something?

nathanfallet commented 1 year ago

I'm going to take a look to tests, but that's not normal if it fails... (also you might need to add tests to cover your new methods) I was wondering, why is your generic method not called with the suffix ifPresent as well? There is already a generic decode method just before your addition.

JacobHearst commented 1 year ago

I was wondering, why is your generic method not called with the suffix ifPresent as well? There is already a generic decode method just before your addition.

An oversight on my part (too much copypasta).

also you might need to add tests to cover your new methods

The SQLiteEncoder and SQLiteDecoder classes are private, are you okay with making them internal to allow for testing?

nathanfallet commented 1 year ago

If they are private that means they are not tested at all... that's scary. I think making them internal and add tests on them could be an all new PR, so feel free to make it if you want to.

JacobHearst commented 1 year ago

I think making them internal and add tests on them could be an all new PR, so feel free to make it if you want to.

I think I'll open up an issue for it if that's alright? I may still come back and open a PR to close that issue but likely not anytime soon