sarc Posted April 7 Posted April 7 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? Quote
wolstech Posted April 7 Posted April 7 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. Quote
sarc Posted April 7 Author Posted April 7 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 Quote
wolstech Posted April 7 Posted April 7 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.