Skip to content
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

Unable to sync updated null value in DB row #179

Open
spendora-app opened this issue Sep 29, 2024 · 1 comment
Open

Unable to sync updated null value in DB row #179

spendora-app opened this issue Sep 29, 2024 · 1 comment

Comments

@spendora-app
Copy link

spendora-app commented Sep 29, 2024

I have followed the supabase and powersync implementation in the supabase-simple-chat demo.

I have a column that has nullable string values. After I update the value to null in the local database via an INSERT OR REPLACE SQL statement. I can see the value in the sqlite database become null. However after a few seconds it seems to re-update its value back to the previous non null value.

I suspect the null update is not being pushed to supabase, but instead it is resetting my local to be in sync with supabase instead.

To strangely when i use an UPDATE instead of an INSERT OR REPLACE, it seems to work fine.

Hoping someone could advise on how to manage this?

@rkistner
Copy link
Contributor

Values being reverted typically happens when your uploadData function calls .complete() on the batch/transaction without it having uploaded successfully. So the first thing to check is your application logs to see if you have any errors in your uploadData function (and make sure that errors are always logged in that function).

The difference between UPDATE and INSERT OR REPLACE is that a REPLACE operation is recorded as a DELETE + INSERT. So if you have for example a RLS rule that blocks deletes, that could explain the UPDATE working but INSERT OR REPLACE not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants