#24343 closed Bug (fixed)
UUID foreign key accessor returns inconsistent type
Reported by: | Tim Graham | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8alpha1 |
Severity: | Release blocker | Keywords: | |
Cc: | me@…, cmawebsite@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Current test failure on Oracle (and it's an issue on other backends but tests are skipped on other backends besides Oracle and PostgreSQL due to @skipUnlessDBFeature("can_defer_constraint_checks")
:
Traceback (most recent call last): File "/mnt/jenkinsdata/workspace/django-oracle/database/oracle11/python/python2.7/django/utils/functional.py", line 15, in _curried return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs)) File "/mnt/jenkinsdata/workspace/django-oracle/database/oracle11/python/python2.7/tests/serializers_regress/tests.py", line 479, in serializerTest func[1](self, pk, klass, datum) File "/mnt/jenkinsdata/workspace/django-oracle/database/oracle11/python/python2.7/tests/serializers_regress/tests.py", line 154, in fk_compare testcase.assertEqual(data, instance.data_id) AssertionError: UUID('3f57e641-c3c7-4990-be67-f3207e4f5bd2') != u'3f57e641c3c74990be67f3207e4f5bd2'
Give this model:
class FKToUUID(models.Model): data = models.ForeignKey(UUIDData)
obj.data_id
returns a string on all backends except PostgreSQL which returns a UUID. Might be related to the has_native_uuid_field
database features flag.
Change History (9)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Is there a reason why we don't test the fk by accessing it?
That is, shouldn't we be doing something like
testcase.assertEqual(instance.data.pk, data)
?
comment:3 by , 10 years ago
Cc: | added |
---|
comment:4 by , 10 years ago
Cc: | added |
---|
comment:5 by , 10 years ago
For the people following this ticket: My suggestion above does not work, and is in the wrong direction. What appears to be the right direction is Marc's PR, following the little mailing list discussion.
comment:6 by , 10 years ago
Has patch: | set |
---|
comment:7 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
If the current behavior is correct, here's a patch to simply make the test pass: