Use a failable iterator when selecting records#1917
Conversation
|
I added |
|
|
||
| class SQLiteDotSwiftDatabaseBehaviorTests: XCTestCase { | ||
|
|
||
| func testSelection_withForcedError_shouldThrow() throws { |
There was a problem hiding this comment.
@AnthonyMDev is this what you had in mind for a test? Directly calling selectRawRows(forKeys:) is as close to the change as we can get. The table we use is extremely basic so I don't think it's possible to force an error through data without doing something more drastic. So I chose to drop the table instead of the nuclear option like deleting the database.
There was a problem hiding this comment.
I think so! Let's just verify by making sure this test fails once we update to SQLite 13.0.
There was a problem hiding this comment.
We'd have to cherry-pick the test into a branch that doesn't contain the change to use prepareRowIterator - but yes, good validation once we move.
There was a problem hiding this comment.
To prove that this change works I created a branch that:
- Bumped the SQLite.swift dependency version to
0.13.0which contains the iterator behaviour change (from this) - cherry-picked the test from this PR
- Pushed to GitHub to trigger a CI build
The CI build failed as expected which proves the hypothesis that if this change were to go out in a 0.12.3 release then developers using apollo-ios would get silently changed behaviour.
I'm not sure how long CI builds are kept for so for prosperity the screenshot below is from the failed CI build

And all four of those failed steps are failing with the same error

AnthonyMDev
left a comment
There was a problem hiding this comment.
Thanks for this Calvin!
The
preparefunction being used inselectRawRows(forKeys:)is changing behaviour such that errors during iteration would be hidden. We can keep the expected error-on-iteration behaviour by switching to a row iterator that supports failure. This PR changes the internals ofselectRawRows(forKeys:)to useprepareRowIterator, returning aRowIteratorwhich conforms toFailableIteratortherefore any error thrown would still be propagated out to the caller.This PR does not move the dependency version of SQLite.swift to 0.13.0