Re: Using unique_together with foreign key fields which may be None

2013-10-01 Thread Thomas Lockhart
On 10/1/13 6:36 AM, Derek wrote: We encountered the same problem for a complex model ... we ended up defining "acceptable" default values that are used instead of None/NULL, but essentially mean the same thing to the user. (We are using MySQL which adopts the same approach as Postgresql - I

Re: Using unique_together with foreign key fields which may be None

2013-10-01 Thread Derek
We encountered the same problem for a complex model ... we ended up defining "acceptable" default values that are used instead of None/NULL, but essentially mean the same thing to the user. (We are using MySQL which adopts the same approach as Postgresql - I believe Oracle does it otherwise).

Re: Using unique_together with foreign key fields which may be None

2013-09-30 Thread Karen Tracey
On Mon, Sep 30, 2013 at 4:55 PM, Berndt Jung wrote: > Because the lookup_value of a null field is None, the validation check is > aborted entirely. This seems wrong to me, and I'm wondering if I'm doing > something wrong here. Redefining the models is not something I can do at

Re: Using unique_together with foreign key fields which may be None

2013-09-30 Thread Berndt Jung
Well, I may have answered my own question. It looks like per the SQL standard NULL values are unique. Here from the postgres docs: In general, a unique constraint is violated when there are two or more rows in the table where the values of all of the columns included in the constraint are

Using unique_together with foreign key fields which may be None

2013-09-30 Thread Berndt Jung
Hi, I'm having trouble using the unique together constraint with a a field which may be None. Given this model: class Rule(models.Model): internal = models.BooleanField(default=False) port_range_from = models.PositiveIntegerField(null=True, blank=True) port_range_to =