On Tue, Mar 15, 2011 at 7:14 PM, Christophe Pettus <x...@thebuild.com> wrote:
> A concern here is that composite indexes, like unique, are sensitive to the 
> ordering of the fields, which means that the ordering of the fields in the 
> class declaration becomes important.

a simplistic proposal:

the order of the fields on a composite index is determined by the
exact value given to the primary_key argument.

that way, just setting primary_key=True on a few fields won't
guarantee order, but something like:

class City (models.Model):
    country = models.CharField (max_length=2, primary_key=1)
    state = models.CharField (max_length=2, primary_key=2)
    city = models.CharField (max_length=3, primary_key=2)
    Name = models.CharField (max_length=20)

would set the (country,state,city) primary key in the obvious order.

in short: giving any non-falsy value to primary_key would add the
field to the key, the exact value would determine ordering.


-- 
Javier

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

Reply via email to