On Tue, 2008-07-01 at 23:10 -0400, Wanrong Lin wrote:
> Hi,
> 
> This topic has been discussed before here:
> http://groups.google.com/group/django-users/browse_thread/thread/fcd04f766b101a95/b65b70aa6b03729e?lnk=gst&q=unique_together%2C+null#
> 
> Don't you agree that two field combinations like ("A", null) and ("A", 
> null) should be considered identical and hence should be blocked from 
> being entered into the database when "unique_together" condition is 
> imposed on that field combination? Right now Django does not think so 
> and will let both of those two records get into the database, which is 
> really puzzling to me. Any rationale for such a counter-intuitive (to 
> me) behavior?

In SQL, all NULLs are unique (NULL != NULL). So this isn't
counter-intuitive at the SQL level and unique_together is enforced at
that level.

I guess the solution is not to allow NULLs in those fields if you can
avoid it, or manually add a more complex check constraint to the
database table (exact syntax and format will depend upon your database).

Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to