Relations to non-trivial fields

50 views
Skip to first unread message

Shai Berger

unread,
Feb 14, 2015, 1:17:40 PM2/14/15
to django-d...@googlegroups.com
Hi all,

This comes from trying to fix #24343[1] -- a problem where a UUIDField is used
as a PK (legitimate and common practice), and we wish to test a FK to that
model. The problem is that, on database backends which do not support native
UUIDFields (that is, all but postgres), the underlying field for an FK is a
CharField, not a UUIDField. This is not a problem in most normal use, but
sometimes people do access the underlying field, and they're in for a surprise
there.

I am almost certain that a similar problem exists with any non-trivial field --
e.g. if someone had reason to use a CommaSeparatedIntField as a PK, they would
probably run into the same issue.

Now, there are two essential ways to fix the test failure in the ticket: One,
as suggested by Tim in a comment on the ticket, is to just deal with the
difference in the test. The other is to solve the deeper issue, which could be
seen as a little disruptive at this point in the release cycle (and is, in
general, more disruptive).

Note that, as Tim notes on the ticket, the test failure is Oracle only, but
the real issue is everyone-but-postgres.

Opinions?

Thanks,
Shai.

[1] https://code.djangoproject.com/ticket/24343

Collin Anderson

unread,
Feb 14, 2015, 2:13:44 PM2/14/15
to django-d...@googlegroups.com
Long term, eventually we want the FK to use a real models.UUIDField under the hood, right?

Marc Tamlyn

unread,
Feb 14, 2015, 2:40:43 PM2/14/15
to django-d...@googlegroups.com
This issue is that the foreign key field (i.e. the foo_id field) does not have its db_converters called, if they are defined in the backend rather than in the field itself.

I've added a pull request (https://github.com/django/django/pull/4134) with a possible approach to the problem. We may be able to do something better, I'm going to investigate further.

Marc

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFO84S4CF_qo%2BMmJ1ybUsOMfD%3DPTyVxQZy8wD3vYKC6rE5%3DDwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages