tinyplex / tinybase

The reactive data store for local‑first apps.
https://tinybase.org
MIT License
3.23k stars 65 forks source link

Introduce withoutOnConflict flag to sqlite-persister, add type='view' to FROM_PRAGMA_TABLE statement #131

Closed bndkt closed 4 months ago

bndkt commented 5 months ago

Summary

This is the first PR in pursuit of #130. I decided to split up the work in the 1) prerequisites (introducing the ability to read VIEWS and the option to write changes using INSERT OR REPLACE instead of using ON CONFLICT) and 2) the actual PowerSync persister to make this easier to digest. The whole PowerSync adapter is implemented in my fork: https://github.com/bndkt/tinybase/tree/powersync

How did you test this change?

I made sure all existing tests still succeed. I had to adapt the tests that compare expected to actual SQL statements though, as this change changes some SQL statements (adding views).

bndkt commented 4 months ago

Thanks for the great feedback @jamesgpearce! I've implemented the changes you suggested. While flipping the boolean logic, I also noticed that I defined defaults multiple times. I've now changed this to have the default only at the final function where the flag is used, to make it more DRY. Hope you agree with that.

jamesgpearce commented 4 months ago

Very nice! Do you want to keep stacking up all the subsequent changes and merge when it's all ready? Or are you OK with shipping this latent functionality in main now.

(Also there's a v5.0 coming so if you have any breaking API changes coming that will be good timing for those)

bndkt commented 4 months ago

Awesome! My suggestion would be to merge this, all the rest will be purely additional (e.g. new files for the new persister and entries in the build files), I don't anticipate any other changes to existing code. Maybe I'll even get the PR ready before 5.0, the code is done and I "only" have to write comments/docs.

jamesgpearce commented 4 months ago

I take "only" very seriously on this project 😉

jamesgpearce commented 4 months ago

You missed a couple of renames but I just fixed them anyway while I was rebasing. Good to go!