#8784: Add HAVING-clauses to QuerySets
---------------------------------------------------+------------------------
Reporter: Johntron | Owner: nobody
Status: new | Milestone: post-1.0
Component: Database wrapper | Version: SVN
Keywords: db query having clause extra database | Stage: Unreviewed
Has_patch: 1 |
---------------------------------------------------+------------------------
We need some way to include HAVING clauses in QuerySets. The HAVING clause
allows aliases to be used as operands in conditionals. The
db.models.QuerySet.extra() looks like the best method to use for something
like this, so I've added some code to db.models.QuerySet.extra() method
and the corresponding db.models.sql.query.Query class. See patch.
A use case:
{{{
locations = Location.objects.extra( select={'distance': 'SQRT(POW(69.1 *
(lattitude - %f), 2) + POW(69.1 * (longitude - %f) * COS(lattitude/57.3),
2))' % (lat, lng)} )
locations = locations.extra( having=['distance < %f' % maxdist] )
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/8784>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---