-
Notifications
You must be signed in to change notification settings - Fork 24
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
Sync Rules Not Filtering Data Based on client params #234
Comments
Hey @tejas-codiste, firstly just a note on client parameters. They aren't specifically secure as a client could specify any Ignoring the |
Thanks for your kind reply. I went through the shared link, but my question remains the same. I want to load only the data related to user_id, not the entire database. I'm not using Supabase Auth in the app. Could you lease let me know how to achieve this?. |
Okay so the first part would be ensuring that you define the Then you would have something like this (note joins aren't supported in the sync rules yet).
|
Thanks, @Chriztiaan! I'm still facing an issue where the entire PowerSync database is being backed up locally on the device. Could you please review my refactored bucket definitions and the Flutter-side code where I'm passing the user_id to get a better understanding of the issue? Bucket Definitions:
Flutter Code (Passing user_id): Additionally, I’m unable to see the newly created bucket in the Diagnostics Console (screenshot attached). It only shows the global bucket, even though I’ve commented out the global bucket and redeployed the rules. ![]() ![]() Could you help me ensure that only user-specific data is backed up based on user_id? |
@tejas-codiste Are you using a cloud or self-hosted instance? Usually in a case like this where you don't see the sync rule updates being applied, it indicates a likely error in processing your sync rules. The error should be visible in the cloud dashboard, or in the logs of a self-hosted instance (should be visible when starting the instance). |
Here's how my data flow works: I log in to the backend using email & password, which provides a user_id upon successful authentication. Hope this clarifies my setup! |
@tejas-codiste We still need info on whether you're using a cloud or self-hosted PowerSync instance, since the issue is most likely on the PowerSync service. The relevant logs should indicate what the issue is. |
We're using Supabase instance connected to PowerSync, so I believe it should be a cloud instance. |
![]() @rkistner Could you please check the shared the screenshot, There no errors display on console. |
Ok, there appears to be an issue that the errors are not reported in the "replication errors" section - we'll look into that. You can however see the errors highlighted in the sync rules section - the "select not supported here" (subqueries and joins are not supported in sync rules). You may need to create separate buckets per event and per to work around those limitations. For more strategies, see this guide. |
Hi @rkistner , thanks for your guidance. I hope you've reviewed the sync rules. Could you please help me with the refactored sync rules? That would be greatly helpful. |
@tejas-codiste For sync rule advice, it would be best to join our Discord - see the link to join here. |
I am trying to sync only the relevant data based on a
user_id
parameter. However, instead of fetching only the filtered data, the entire database is being synced to the local device.Expected Behavior
Only the data matching the user_id parameter should be synced to the local database.
Actual Behavior
The entire database is synced, ignoring the filtering rules logic in the sync rules.
PowerSync Sync Rules Configuration
I have defined the following sync rule in the PowerSync console:
Flutter Code for Connecting to PowerSync
This issue prevents implementing user-specific data syncing, which is a core requirement for my application. Any guidance on resolving this would be appreciated.
The text was updated successfully, but these errors were encountered: