#24744: hstore lookup inside subquery
----------------------------------+--------------------
Reporter: mrAdm | Owner:
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.8
Severity: Normal | Keywords: hstore
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------
There are two models:
{{{
from django.db import models
from django.contrib.postgres.fields import HStoreField
class A(Model):
test = models.CharField(max_length=100)
hstore = HStoreField()
class B(Model):
a = models.ForeignKey(A)
}}}
Execute the query:
{{{
print B.objects.filter(a__in=A.objects.filter(hstore__field=1))
}}}
I get the following exception:
{{{
Traceback (most recent call last):
File "/vagrant/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 338, in
execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line
18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 115, in populate
app_config.ready()
File "/vagrant/st/apps.py", line 18, in ready
print
str(B.objects.filter(a__in=A.objects.filter(hstore__field=1)).query)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 679, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 697, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/query.py", line 1301, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/query.py", line 1328, in _add_q
current_negated=current_negated, connector=connector,
allow_joins=allow_joins)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/query.py", line 1150, in build_filter
value, lookups, used_joins = self.prepare_lookup_value(value, lookups,
can_reuse, allow_joins)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/query.py", line 1007, in
prepare_lookup_value
value.query.bump_prefix(self)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/query.py", line 868, in bump_prefix
self.change_aliases(change_map)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/query.py", line 792, in change_aliases
self.where.relabel_aliases(change_map)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/sql/where.py", line 287, in relabel_aliases
self.children[pos] = child.relabeled_clone(change_map)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/lookups.py", line 178, in relabeled_clone
new.lhs = new.lhs.relabeled_clone(relabels)
File "/usr/local/lib/python2.7/dist-
packages/django/db/models/lookups.py", line 76, in relabeled_clone
return self.__class__(self.lhs.relabeled_clone(relabels))
File "/usr/local/lib/python2.7/dist-
packages/django/contrib/postgres/fields/hstore.py", line 76, in __init__
super(KeyTransform, self).__init__(*args, **kwargs)
TypeError: __init__() takes exactly 3 arguments (1 given)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24744>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.233a9e84965e19f750953351d2228121%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.