Closed SteveAyre closed 9 years ago
Having the hyphenated form within the database isn't sufficient to correct the error. Below are the queries from the MySQL general log.
SELECT portal_application
.id
, portal_application
.code
, portal_application
.description
FROM portal_application
WHERE portal_application
.id
= '356420a0-1e24-11e4-96f4-080027dcfac6'
-- this is fine, returns the row
SELECT (1) AS a
FROM portal_application
WHERE portal_application
.id
= '356420a01e2411e496f4080027dcfac6' LIMIT 1
-- this is not fine as the unhyphenated value doesn't match
This gives the error: application instance with pk UUID('356420a0-1e24-11e4-96f4-080027dcfac6') does not exist.
It appears hyphenate is intended as a display-only option, with hyphens never used in the database? Is that correct?
In this case the issue is only that the form submits the hyphenated form, which is then not found in the database as it isn't converted to the unhyphenated form.
Also would it be possible to choose to store the hyphenated version in the database, as sometimes this might be required for interop with other utilities.
This was fixed by caae1bc4e45445a06dd11bb22da6a9f07395f78a
@dcramer you can close this
Since you responded so fast on the last one: this can also be closed ;)
Created two models with a UUIDField(primary_key=True,hyphenate=True,auto=True) fields. One model has a foreign key to the other model.
Fixture fields contain UUIDs with hyphens.
Problem 1: loaddata loads the UUIDs into the database with hyphens removed
Problem 2: generic.edit.CreateView fails due to a foreign key problem - the form is submitted with a hyphenated UUID, this appears to fail since it is stored without hyphens in the database