Skip to content

Commit

Permalink
FAN-3894 - Fixed checking of db_type, including case where method doe…
Browse files Browse the repository at this point in the history
…sn't exist
  • Loading branch information
Oli Yu committed Jul 28, 2011
1 parent 0d77e10 commit 16bb9e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django_hstore/query.py
Expand Up @@ -48,7 +48,7 @@ class HStoreWhereNode(WhereNode):
def make_atom(self, child, qn, connection):
lvalue, lookup_type, value_annot, param = child
kwargs = {'connection': connection} if VERSION[:2] >= (1, 3) else {}
if lvalue and lvalue.field and lvalue.field.db_type(**kwargs) == 'hstore':
if lvalue and lvalue.field and hasattr(lvalue.field, 'db_type') and lvalue.field.db_type(**kwargs) == 'hstore':
try:
lvalue, params = lvalue.process(lookup_type, param, connection)
except EmptyShortCircuit:
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.py
Expand Up @@ -47,6 +47,11 @@ def test_aggregates(self):
self.assertEqual(DataBag.objects.filter(data__contains={'b0':'1'}).aggregate(Count('id'))['id__count'], 5)
self.assertEqual(DataBag.objects.filter(data__contains={'b1':'1'}).aggregate(Count('id'))['id__count'], 4)

def test_annotations(self):
self._create_bitfield_bags()

self.assertEqual(DataBag.objects.annotate(num_id=Count('id')).filter(num_id=1)[0].num_id, 1)

def test_nested_filtering(self):
self._create_bitfield_bags()

Expand Down

0 comments on commit 16bb9e8

Please sign in to comment.