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

Inconsistent backend UUID values in method get_db_prep_value() #49

Open
lingxiaoyang opened this issue Dec 10, 2014 · 3 comments
Open

Comments

@lingxiaoyang
Copy link

Besides #46, another issue with method get_db_prep_value is inconsistency of hyphens.

Let's say we pass the value as a UUID object UUID('00010203-0405-0607-0809-0a0b0c0d0e0f'). The method returns str(value), which, according to Python doc, is stringified with hyphen '00010203-0405-0607-0809-0a0b0c0d0e0f'. However, if we pass a string '00010203-0405-0607-0809-0a0b0c0d0e0f', the method will return a non-hyphen version of it. It doesn't matter with PostgreSQL which supports UUID type, but for other backends where UUID is stored as a char32 the inconsistency would be a problem.

@ksonbol
Copy link
Contributor

ksonbol commented Dec 10, 2014

But if the field is nullable won't this return existing objects with a null UUID when using an anvalid UUID in lookup?

@lingxiaoyang
Copy link
Author

@ksonbol That's right -- I didn't consider the null=True situation...
Thus it seems returning an arbitrary UUID is the only way to work around this problem?

@lingxiaoyang
Copy link
Author

@ksonbol It seems that UUIDField is designed to be an auto field...
https://github.com/dcramer/django-uuidfield/blob/master/uuidfield/tests/tests.py#L19-L20

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

2 participants