Opened 10 years ago
Last modified 2 years ago
#26056 closed New feature
ArrayField does not work with ValueListQuerySet — at Initial Version
| Reported by: | Przemek | Owned by: | |
|---|---|---|---|
| Component: | contrib.postgres | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Basically queries of type:
A.objects.filter(array_field__overlap=B.objects.filter(foo))
fail at Python level:
Traceback (most recent call last):
File "failing.py", line 9, in <module>
UserList.objects.filter(users__overlap=User.objects.all().values_list('id', flat=True)).count()
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/query.py", line 318, in count
return self.query.get_count(using=self.db)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/query.py", line 466, in get_count
number = obj.get_aggregation(using, ['__count'])['__count']
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/query.py", line 447, in get_aggregation
result = compiler.execute_sql(SINGLE)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line 829, in execute_sql
sql, params = self.as_sql()
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line 387, in as_sql
where, w_params = self.compile(self.query.where)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line 357, in compile
sql, params = node.as_sql(self, self.connection)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/where.py", line 104, in as_sql
sql, params = compiler.compile(child)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/db/models/sql/compiler.py", line 357, in compile
sql, params = node.as_sql(self, self.connection)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/contrib/postgres/fields/array.py", line 183, in as_sql
sql, params = super(ArrayOverlap, self).as_sql(qn, connection)
File "/home/przemek/.virtualenvs/italamo/lib/python2.7/site-packages/Django-1.8.5-py2.7.egg/django/contrib/postgres/lookups.py", line 8, in as_sql
params = lhs_params + rhs_params
TypeError: can only concatenate list (not "tuple") to list
Toy project to reproduce this behavior can be found here: https://github.com/CGenie/django_array_join_fail
This fails in 1.8 as well as in 1.9.
Note:
See TracTickets
for help on using tickets.