electric-sql / electric

Local-first sync layer for web and mobile apps. Build reactive, realtime, local-first apps directly on Postgres.
https://electric-sql.com
Apache License 2.0
5.47k stars 125 forks source link

Issue with ElectricSQL when I try to change the content of an entry in the database #1321

Open SukiTUK opened 1 month ago

SukiTUK commented 1 month ago

Hello Team,

The file I am trying to execute is https://github.com/SukiTUK/SpreadsheetWithElectric/blob/main/my-app/src/Example.tsx#L294 -> function handlecellblur

To start the app >

  1. run electric server "npx electric-sql start --with-postgres"
  2. Goto my-app folder and run "npm run dev"

Steps to reproduce: In the application,

  1. add a row.
  2. add a column.
  3. enter a content in the cell and click anywhere outside to trigger the write to the database. Result: There is an entry created in the database contentmap
  4. Again change the content of the same cell and click anywhere outside to trigger the write to the database. Result: There is the following error on the console.

Uncaught (in promise) ZodError at get error (index.mjs:537:31) at _ZodObject.parse (index.mjs:636:22) at validate (validation.ts:15:31) at Table._update (table.ts:1314:34) at table.ts:354:12 at executor.ts:49:7 at Promise.catch._run.sql (adapter.ts:67:7) at new Promise () at DatabaseAdapter2.transaction (adapter.ts:58:12) at async Executor.transaction (executor.ts:48:13)

Could you please help me with this issue?

linear[bot] commented 1 month ago

VAX-1891 Issue with ElectricSQL when I try to change the content of an entry in the database

stildalf commented 1 month ago

Hey @SukiTUK, we can't see your code sample, it's in a private repo.

SukiTUK commented 1 month ago

Hey @SukiTUK, we can't see your code sample, it's in a private repo.

@stildalf I have made the repository public. Could you check?

msfstef commented 4 weeks ago

@SukiTUK issue has been addressed in the Discord help and support channel.

Problem seems to be that your schema uses composite PK that includes FK columns that also have update cascades on them, and Electric requires immutable primary keys.

You can read @alco's and @samwillis' replies for more details in the thread. Hope this covers the question!