.. changelog::
:version: 1.0.5
+ .. change::
+ :tags: feature, ext
+ :pullreq: bitbucket:54
+
+ Added support for ``*args`` to be passed to the baked query
+ initial callable, in the same way that ``*args`` are supported
+ for the :meth:`.BakedQuery.add_criteria` and
+ :meth:`.BakedQuery.with_criteria` methods. Initial PR courtesy
+ Naoki INADA.
+
.. change::
:tags: bug, engine
:tickets: 3435
__slots__ = 'steps', '_bakery', '_cache_key', '_spoiled'
def __init__(self, bakery, initial_fn, args=()):
- if args:
- self._cache_key = tuple(args)
- else:
- self._cache_key = ()
- self._update_cache_key(initial_fn)
+ self._cache_key = ()
+ self._update_cache_key(initial_fn, args)
self.steps = [initial_fn]
self._spoiled = False
self._bakery = bakery
_bakery = util.LRUCache(size)
- def call(initial_fn, args=()):
+ def call(initial_fn, *args):
return cls(_bakery, initial_fn, args)
return call
})
mapper(Address, cls.tables.addresses)
+ def test_cachekeys_on_constructor(self):
+ User = self.classes.User
+
+ queue = [7, 8]
+ fn = lambda s: s.query(User.id).filter_by(id=queue.pop(0))
+ bq1 = self.bakery(fn, 7)
+ bq2 = self.bakery(fn, 8)
+
+ for i in range(3):
+ session = Session(autocommit=True)
+ eq_(
+ bq1(session).all(),
+ [(7,)]
+ )
+
+ eq_(
+ bq2(session).all(),
+ [(8,)]
+ )
+
def test_no_steps(self):
User = self.classes.User