-
Notifications
You must be signed in to change notification settings - Fork 730
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prove that this change works I created a branch that:
- Bumped the SQLite.swift dependency version to
0.13.0
which 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this Calvin!
The
prepare
function 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 aRowIterator
which conforms toFailableIterator
therefore 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