electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.21k stars 146 forks source link

Undestanding why defaults are not supported #1420

Closed chris-braidwell closed 1 month ago

chris-braidwell commented 3 months ago

I understand electric-sql will only ever support a subset of Postgres -- certain things can't be done safely or at all when all data isn't in-scope at the time of the operation, fair enough. Like UNIQUE constraints, got it. Can you help me understand why DEFAULT isn't supported? I can't think of why for example is_open BOOLEAN DEFAULT FALSE would be a problem.

linear[bot] commented 3 months ago

VAX-2003 Undestanding why defaults are not supported

AntonOfTheWoods commented 3 months ago

This is a question, and has already been answered on discord. Try searching there.

chris-braidwell commented 2 months ago

I've found lots of discussion re: DEFAULT but haven't one that explains why. Can someone provide a link?

AntonOfTheWoods commented 2 months ago

Because there are several ways of generating the default values, some of which are not trivial to convert to SQLite. As the discussions mention, there is an idea to make some defaults possible later, and possibly most if you are using pglite.

This is still a discussion topic though, and should not be in an issue...

alco commented 2 months ago

@chris-braidwell We can't support any Postgres expression as the default when mapping a PG schema to SQLite, so to keep things predictable and avoid causing sync issues for people who electrified tables Electric couldn't support, we added a check to make it clear that columns with DEFAULT clauses couldn't be electrified.

There are paths to partial support of defaults, we just didn't have enough capacity to address the issue.

Our team has now switched focus to https://github.com/electric-sql/electric-next?tab=readme-ov-file#electric-next. I suggest you take a look at it, there are no schema restrictions there while we're working on the "read path". And once we get to the "write path", i.e. syncing client writes to Postgres, the approach will be different there from what has been implemented in Electric so far.

KyleAMathews commented 1 month ago

👋 we've been working the last month on a rebuild of the Electric server over at a temporary repo https://github.com/electric-sql/electric-next/

You can read more about why we made the decision at https://next.electric-sql.com/about

We're really excited about all the new possibilities the new server brings and we hope you'll check it out soon and give us your feedback.

We're now moving the temporary repo back here. As part of that migration we're closing all the old issues and PRs. We really appreciate you taking the time to investigate and report the bug!