(since its not polymorphic) which breaks in bi-directional relationships
(i.e. C has its A, but A's backref will lazyload it as a different
instance of type "B") [ticket:500]
+- extensions:
+ - options() method on SelectResults now implemented "generatively"
+ like the rest of the SelectResults methods [ticket:472]
0.3.5
- sql:
self._joinpoint = joinpoint or (self._query.table, self._query.mapper)
def options(self,*args, **kwargs):
- """Transform the original mapper query form to an alternate form
+ """Apply mapper options to the underlying query.
See also ``Query.options``.
"""
- self._query = self._query.options(*args, **kwargs)
+ new = self.clone()
+ new._query = new._query.options(*args, **kwargs)
+ return new
def count(self):
"""Execute the SQL ``count()`` function against the ``SelectResults`` criterion."""
assert self.res.filter(Foo.c.bar < 30).count() == 30
res2 = self.res.filter(Foo.c.bar < 30).filter(Foo.c.bar > 10)
assert res2.count() == 19
+
+ def test_options(self):
+ class ext1(MapperExtension):
+ def populate_instance(self, mapper, selectcontext, row, instance, identitykey, isnew):
+ instance.TEST = "hello world"
+ return EXT_PASS
+ objectstore.clear()
+ assert self.res.options(extension(ext1()))[0].TEST == "hello world"
def test_order_by(self):
assert self.res.order_by([Foo.c.bar])[0].bar == 0