On Mar 21, 2011, at 12:20 PM, Jacob Kaplan-Moss wrote: > I think we're talking slightly different concerns here: I'm mostly > interested in the Python-side API, and to my eyes a composite field > matches more closely what's happening on the Python side of things.
I agree 100%! I think I'm just drawing a different conclusion from that point, which is that indexes are more metadata on the database rather than a critical part of the Python API: In an imaginary perfect database (like, say, the SQL spec envisions), we wouldn't need to talk about indexes as all. The more I think about it, the less I like including this directly in the field declaration part of the model, including my Index type proposal. It just doesn't seem to belong there. What concerns me about composite fields is that they seem to be a lot of Python machinery just to accomplish the goal of allowing this annotation. If they were super-useful in their own right, that would be one thing, but I'm not sure that I see the utility of them absent indexes and foreign keys. I'm also bothered, perhaps excessively, about having two different ways of getting at the same field in the model just to support this. So, another proposal: In the foreign key case, just extending the ForeignKey syntax to allow for multiple related fields makes the most sense: overThere = models.ForeignKey(OtherModel, to_field=('first_name', 'last_name', )) For indexes on the table for the model, include the declaration in the Meta class, since that's the obvious place to stick indexing: class SomeModel: class Meta: primary_key = 'some_field' indexes = ['some_field', 'some_other_field', ('field1', '-field2', ), ] raw_indexes = [ 'some_invariant_function(some_field)' ] (This was proposed by someone else, and isn't original to me; apologies that I can't find the email to give credit.) Of course, the existing syntax would still work as a shortcut for primary_key and indexes. Thoughts? -- -- Christophe Pettus x...@thebuild.com -- 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.