Here's a couple of patches I've been using locally with some success.
The first implements DISTINCT. It behaves a lot like reverse(): you can
either say:
Foo.select(..., distinct=True)
or
res = Foo.select(...)
res.distinct()
# use res...
This only applies to explicit select() calls. It doesn't really combine
properly with count(*) either; it seems the correct way to do that is
count(distinct *), but sqlite (my testing DB) doesn't implement that,
and needs a much more complex variant using DISTINCT sub-selects. So
I've ignored that for now.
The second is an updated version of the patch I posted the other day.
It allows you to specify indexes when defining a table class. There's
an example at the top of the patch.
Both patches are against the current SVN head.
I'd be interested to know if anyone finds these useful, or if I'm just
barking up the wrong tree.
Thanks,
J
|