Permalink
Browse files

fixed issue #50

  • Loading branch information...
1 parent 4dce2c8 commit 875c869bbdd02a3d987b9201293c18eec2de118e quantmind committed Nov 27, 2012
Showing with 25 additions and 7 deletions.
  1. +3 −0 CHANGELOG.rst
  2. +1 −1 stdnet/__init__.py
  3. +4 −1 stdnet/backends/redisb.py
  4. +15 −2 tests/regression/query/meta.py
  5. +2 −3 tests/regression/query/slice.py
View
@@ -2,6 +2,9 @@
Ver. 0.7.1 - Development
===============================
+* Splicing a query in conjunction with :meth:`stdnet.odm.Q.get_field` request
+ throws a :class:`stdnet.QuerySetException`. See issue #50.
+* **627 regression tests** with **92%** coverage.
Ver. 0.7.0 - 2012 Oct 25
===============================
View
@@ -3,7 +3,7 @@
from .backends import *
from .utils.version import get_version, stdnet_version
-VERSION = stdnet_version(0, 7, 0, 'final', 1)
+VERSION = stdnet_version(0, 7, 1, 'beta', 1)
__version__ = version = get_version(VERSION)
__license__ = "BSD"
@@ -7,7 +7,7 @@
from collections import namedtuple
import stdnet
-from stdnet import FieldValueError, CommitException
+from stdnet import FieldValueError, CommitException, QuerySetError
from stdnet.utils import to_string, map, gen_unique_id, zip,\
native_str, flat_mapping, unique_tuple
from stdnet.lib import redis
@@ -314,6 +314,9 @@ def _items(self, slic):
pkname_tuple = (meta.pk.name,)
# if the get_field is available, we only load that field
if get:
+ if slic:
+ raise QuerySetError('Cannot slice a queryset in conjunction '
+ 'with get_field. Use load_only instaed.')
if get == meta.pk.name:
fields_attributes = fields = pkname_tuple
else:
@@ -39,8 +39,21 @@ def test_getfield(self):
self.assertEqual(query,query2)
def testFilterError(self):
- query = Instrument.objects.filter(whoaaaaa = 'foo')
+ query = Instrument.objects.filter(whoaaaaa='foo')
self.assertRaises(QuerySetError, query.all)
+ def testRepr(self):
+ self.data.create(self)
+ query = Instrument.objects.filter(ccy='EUR')\
+ .exclude(type=('equity','bond'))
+ self.assertTrue(str(query))
+ # The query is still lazy
+ self.assertFalse(query.cache())
+ v = query.all()
+ self.assertTrue(v)
+ self.assertEqual(str(query), str(v))
-
+ def testEmptyParameters(self):
+ query = Instrument.objects.filter(ccy='USD')
+ self.assertEqual(query, query.filter())
+ self.assertEqual(query, query.exclude())
@@ -1,5 +1,5 @@
'''Slice Query to obtain subqueries.'''
-from stdnet import test
+from stdnet import test, QuerySetError
from examples.models import Instrument
from examples.data import FinanceTest
@@ -71,6 +71,5 @@ def testSliceGetField(self):
'''test silve in conjunction with get_field method'''
session = self.session()
qs = session.query(self.model).get_field('id')
- q1 = qs[:2]
- self.assertEqual(len(q1), 2)
+ self.assertRaises(QuerySetError, lambda: qs[:2])

0 comments on commit 875c869

Please sign in to comment.