-
Notifications
You must be signed in to change notification settings - Fork 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
feat: added watch()
to Drizzle and Kysely integrations
#414
Conversation
🦋 Changeset detectedLatest commit: d6d9c10 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
We had a similar issue with Kysely and useQuery hooks a while back: There, the issue was solved by using |
I agree with this to some extent @rkistner. Solving this problem in a way that also improves watch support in Kysely would be great. However we already overloading the As a possible compromise, could we consider a central watch function implementation (also in common as a util perhaps) that takes in a compilable query. This would then be wrapped for both the Drizzle and Kysely integrations. If we still prefer to have this watch signature on the AbstractPowerSyncDatabase API, I would prefer if we had it under a different name (but that might make the API become even more confusing). |
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.
Ok, that makes sense. Happy to go with this approach for now and then potentially re-evaluate later.
06a6a74
06a6a74
to
ff11c5a
Compare
watch()
to Drizzle integrationwatch()
to Drizzle and Kysely integrations
FYI @stevensJourney @rkistner: |
This PR improves support for watched queries with Drizzle and Kysely by adding a dedicated
watch()
implementation to each package.The original report problem showed a limitation with using Drizzle's
toSQL()
helper with relational queries which you needed to use Powersync'swatch
function:Output:
This is because with some relational queries
toSQL()
invocations will return a query that containsselect json_array
for the joined values - which Drizzle would map internally.The solution is to call
execute()
on the queries directly instead of mapping the queries withtoSQL()
.