Jump to content

Recommended Posts

Posted

Hi, im having some issues with my database, locally i didnt have this problem but know each action to save in DB drops a message showing that the pk can't start as '0', you know how to fix it? or how to avoid the 0 as a pk?

Posted

Can you post the exact error message?

Also, what database type are you using, and what database server did you use locally on your computer when testing? If it's mysql, note that our servers are running the latest version of MariaDB, which, while a fork of MySQL that is extremely compatible, may vary slightly in its behavior.

Posted
1 hour ago, wolstech said:

Can you post the exact error message?

Also, what database type are you using, and what database server did you use locally on your computer when testing? If it's mysql, note that our servers are running the latest version of MariaDB, which, while a fork of MySQL that is extremely compatible, may vary slightly in its behavior.

This is what happens, locally i have the library mysqlclient V.2.2.4 with MariaDB 11.5.2

captura2.thumb.png.7d564a2c078dfe33e87f8c8caeee1dbb.png

Posted

Well, first I should correct myself on MariaDB...we use 10.5, not 11.5, so not the latest version (and in fact quite old).

Some research on this suggests that this error is usually due to bad SQL syntax. The error means something in your SQL is trying to set a foreign key to an invalid value of 0. MySQL doesn't (or isn't supposed to) let FKs pointed to automatic primary key (auto increment) fields be 0...the reference would be invalid since automatic fields in MySQL start at 1 and are always a positive integer. If there's no correct value for a foreign key, it should be null , not 0.

Whether the 0 being fed into that function is the result of Django doing something weird, being broken/different version, or you just have bad code is beyond my knowledge.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...