-
Notifications
You must be signed in to change notification settings - Fork 6
Watched Query Fixes #26
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1e4fee9
update watch implementation
stevensJourney c4f14d6
cleanup
stevensJourney 0e9e826
Merge remote-tracking branch 'origin/main' into watches
stevensJourney 55d93f8
update packages
stevensJourney 07d6c9f
hack fix watch exceptions
stevensJourney ded94a8
cleanup
stevensJourney e78f238
cleanup
stevensJourney fc636be
update changelog
stevensJourney 2008e35
update changelog
stevensJourney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 5 additions & 5 deletions
10
Demo/PowerSyncExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,13 +198,13 @@ final class KotlinPowerSyncDatabaseImplTests: XCTestCase { | |
|
||
// Create an actor to handle concurrent mutations | ||
actor ResultsStore { | ||
private var results: [[String]] = [] | ||
private var results: Set<String> = [] | ||
|
||
func append(_ names: [String]) { | ||
results.append(names) | ||
results.formUnion(names) | ||
} | ||
|
||
func getResults() -> [[String]] { | ||
func getResults() -> Set<String> { | ||
results | ||
} | ||
|
||
|
@@ -213,14 +213,16 @@ final class KotlinPowerSyncDatabaseImplTests: XCTestCase { | |
} | ||
} | ||
|
||
|
||
let resultsStore = ResultsStore() | ||
|
||
let stream = try database.watch( | ||
sql: "SELECT name FROM users ORDER BY id", | ||
parameters: nil | ||
) { cursor in | ||
cursor.getString(index: 0)! | ||
} | ||
options: WatchOptions( | ||
sql: "SELECT name FROM users ORDER BY id", | ||
mapper: { cursor in | ||
cursor.getString(index: 0)! | ||
} | ||
)) | ||
|
||
let watchTask = Task { | ||
for try await names in stream { | ||
|
@@ -240,13 +242,18 @@ final class KotlinPowerSyncDatabaseImplTests: XCTestCase { | |
sql: "INSERT INTO users (id, name, email) VALUES (?, ?, ?)", | ||
parameters: ["2", "User 2", "[email protected]"] | ||
) | ||
|
||
|
||
await fulfillment(of: [expectation], timeout: 5) | ||
watchTask.cancel() | ||
|
||
let finalResults = await resultsStore.getResults() | ||
XCTAssertEqual(finalResults.count, 2) | ||
XCTAssertEqual(finalResults[1], ["User 1", "User 2"]) | ||
// The count of invocations here can vary a lot depending on the order of execution | ||
// In some cases the creation of the users can fire before the initial watched query | ||
// has emitted a result. | ||
// However the watched query should always emit the latest result set. | ||
XCTAssertLessThanOrEqual(finalResults.count, 3) | ||
XCTAssertEqual(finalResults, ["User 1", "User 2"]) | ||
} | ||
|
||
func testWatchError() async throws { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.