-
Notifications
You must be signed in to change notification settings - Fork 175
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
chore(electric): Reject tables that have columns with DEFAULT expressions #509
Conversation
VAX-1100 Electrifying a table with `DEFAULT gen_random_uuid()` yields a broken default "gen_random_uuid" string in SQLite
Reported in Discord: https://discord.com/channels/933657521581858818/1079688869852753981/1156299210400989194 TLDR: The table below electrifies without problems:
However, the default values gets translated to Proposed fix: check for
Postgres has a vastly larger set of built-in functions and expressions compared to SQLite. We cannot possibly allow electrification of tables with arbitrary |
ff0c722
to
1a93b31
Compare
@alco I think this PR might be too strict. I think a better approach would be to remove default expressions from sqlite and keep them in progress. The prisma client can ensure those fields with default expressions are not optional on the client side. |
@gorbak25 I agree that it's strict. But it's aimed at fixing a very particular problem. Whether we skip DEFAULT clauses from the client schema or add support for limited expressions there, both require some planning and development time. In the time window between now and when we release a version with a proper fix, people who electrify their tables containing DEFAULT clauses will get broken server sync when trying out Electric. We would prefer to make it known upfront that a given table cannot be electrified and relax this limitation later. |
1a93b31
to
d7217db
Compare
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.
Looks good apart from function->procedure switch
...ts/electric/lib/electric/postgres/extension/functions/validate_table_column_defaults.sql.eex
Outdated
Show resolved
Hide resolved
I just stumbled on to this, getting an error when trying to electrify a table. |
Yes, this should be documented. I've raised an issue [VAX-1405]. It will be relaxed in future. I don't have visibility on timeframe though. |
Fixes VAX-1100.
%I