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

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

Open
SukiTUK opened this issue Jun 4, 2024 · 4 comments
Assignees

Comments

@SukiTUK
Copy link

SukiTUK commented Jun 4, 2024

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?

@stildalf
Copy link

stildalf commented Jun 4, 2024

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

@SukiTUK
Copy link
Author

SukiTUK commented Jun 5, 2024

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
Copy link
Contributor

msfstef commented Jun 17, 2024

@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!

@msfstef msfstef self-assigned this Jun 17, 2024
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

3 participants