The django-refsql package implements a limited subset of this. You can
reference to columns in an existing ORM query using {{field}} syntax.
For example:
User.objects.annotate(ref=RefSQL("case when {{best_friend__age}} >
{{age}} then 'older' else 'younger' end"))
This would also set up a join to Us
Marcin is correct. The plan is to extend the concept of expressions so that
you have more control over crafting your own queries.
What we have:
- select expressions
- aggregation expressions
- case/when
- order by
- where expressions (lookups/transforms)
- column expressions (representing model
On Thursday, August 27, 2015 at 9:43:40 PM UTC+2, Alexey Zankevich wrote:
>
> For such cases it's great to have DSL to build SQL queries, but it's a big
> question how low- or high-level language should be.
>
Take a look at SQLAlchemy`s expressions API. The ORM is built top of it.
I think that