Fix extremely bizarre issue in which the query using db_model in conjunction with other fields behaved as if it was unindexed if it did not include __iexact keyword. I have absolutely no idea why it acted this way. But __iexact added resolves it.
This commit is contained in:
parent
74cf15b257
commit
f6626e1bf8
1 changed files with 3 additions and 3 deletions
|
|
@ -219,7 +219,7 @@ class AttributeHandler(object):
|
||||||
def _fullcache(self):
|
def _fullcache(self):
|
||||||
"""Cache all attributes of this object"""
|
"""Cache all attributes of this object"""
|
||||||
query = {"%s__id" % self._model: self._objid,
|
query = {"%s__id" % self._model: self._objid,
|
||||||
"attribute__db_model": self._model,
|
"attribute__db_model__iexact": self._model,
|
||||||
"attribute__db_attrtype": self._attrtype}
|
"attribute__db_attrtype": self._attrtype}
|
||||||
attrs = [conn.attribute for conn in getattr(self.obj, self._m2m_fieldname).through.objects.filter(**query)]
|
attrs = [conn.attribute for conn in getattr(self.obj, self._m2m_fieldname).through.objects.filter(**query)]
|
||||||
self._cache = dict(("%s-%s" % (to_str(attr.db_key).lower(),
|
self._cache = dict(("%s-%s" % (to_str(attr.db_key).lower(),
|
||||||
|
|
@ -273,7 +273,7 @@ class AttributeHandler(object):
|
||||||
return [] # no such attribute: return an empty list
|
return [] # no such attribute: return an empty list
|
||||||
else:
|
else:
|
||||||
query = {"%s__id" % self._model: self._objid,
|
query = {"%s__id" % self._model: self._objid,
|
||||||
"attribute__db_model": self._model,
|
"attribute__db_model__iexact": self._model,
|
||||||
"attribute__db_attrtype": self._attrtype,
|
"attribute__db_attrtype": self._attrtype,
|
||||||
"attribute__db_key__iexact": key.lower(),
|
"attribute__db_key__iexact": key.lower(),
|
||||||
"attribute__db_category__iexact": category.lower() if category else None}
|
"attribute__db_category__iexact": category.lower() if category else None}
|
||||||
|
|
@ -298,7 +298,7 @@ class AttributeHandler(object):
|
||||||
else:
|
else:
|
||||||
# we have to query to make this category up-date in the cache
|
# we have to query to make this category up-date in the cache
|
||||||
query = {"%s__id" % self._model: self._objid,
|
query = {"%s__id" % self._model: self._objid,
|
||||||
"attribute__db_model": self._model,
|
"attribute__db_model__iexact": self._model,
|
||||||
"attribute__db_attrtype": self._attrtype,
|
"attribute__db_attrtype": self._attrtype,
|
||||||
"attribute__db_category__iexact": category.lower() if category else None}
|
"attribute__db_category__iexact": category.lower() if category else None}
|
||||||
attrs = [conn.attribute for conn
|
attrs = [conn.attribute for conn
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue