From: Mike Bayer Date: Mon, 14 Feb 2011 03:30:00 +0000 (-0500) Subject: - Beaker example now takes into account 'limit' X-Git-Tag: rel_0_7b2~1^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6458094024107e81eb7c9be140a1a385d26071a6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Beaker example now takes into account 'limit' and 'offset', bind params within embedded FROM clauses (like when you use union() or from_self()) when generating a cache key. --- diff --git a/CHANGES b/CHANGES index 7ec279ac69..16c6788680 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,12 @@ CHANGES collection (i.e. the reverse of the 'typical' association proxy use case) [ticket:2054] +- examples + - Beaker example now takes into account 'limit' + and 'offset', bind params within embedded + FROM clauses (like when you use union() or + from_self()) when generating a cache key. + 0.7.0b1 ======= - Detailed descriptions of each change below are diff --git a/examples/beaker_caching/caching_query.py b/examples/beaker_caching/caching_query.py index 4af812500f..4240e7e138 100644 --- a/examples/beaker_caching/caching_query.py +++ b/examples/beaker_caching/caching_query.py @@ -121,8 +121,9 @@ def _get_cache_parameters(query): if cache_key is None: # cache key - the value arguments from this query's parameters. - args = _params_from_query(query) - cache_key = " ".join([str(x) for x in args]) + args = [str(x) for x in _params_from_query(query)] + args.extend([str(query._limit), str(query._offset)]) + cache_key = " ".join(args) assert cache_key is not None, "Cache key was None !" @@ -269,4 +270,6 @@ def _params_from_query(query): v.append(value) if query._criterion is not None: visitors.traverse(query._criterion, {}, {'bindparam':visit_bindparam}) + for f in query._from_obj: + visitors.traverse(f, {}, {'bindparam':visit_bindparam}) return v