python - How can I add a JOIN and a GROUP BY with an unnested array to a Django ORM query? -
in existing system, i'm using django values()
followed annotate()
pattern effect sql group by
.
however, new feature, need join whole query additional array, , need group by
elements of additional array. in postgresql, looks (greatly simplified):
select count(id) some_table inner join ... inner join (select unnest(array['a', 'b', 'c']) name) tag on some_table.t tag.name || '%' group (some_table.some_column, tag.name);
i stay in orm-land, because query goes through whole sequence of follow-up transformations keep consistent.
is there way in can 1) join runtime-defined (different every query) array , 2) add existing group by
sequence?
Comments
Post a Comment