.. changelog::
:version: 0.8.1
+ .. change::
+ :tags: bug, examples
+
+ Fixed a long-standing bug in the caching example, where
+ the limit/offset parameter values wouldn't be taken into
+ account when computing the cache key. The
+ _key_from_query() function has been simplified to work
+ directly from the final compiled statement in order to get
+ at both the full statement as well as the fully processed
+ parameter list.
+
.. change::
:tags: bug, mssql
:tickets: 2355
"""
- v = []
- def visit_bindparam(bind):
-
- if bind.key in query._params:
- value = query._params[bind.key]
- elif bind.callable:
- value = bind.callable()
- else:
- value = bind.value
-
- v.append(unicode(value))
-
stmt = query.statement
- visitors.traverse(stmt, {}, {'bindparam': visit_bindparam})
+ compiled = stmt.compile()
+ params = compiled.params
# here we return the key as a long string. our "key mangler"
# set up with the region will boil it down to an md5.
- return " ".join([unicode(stmt)] + v)
+ return " ".join(
+ [unicode(compiled)] +
+ [unicode(params[k]) for k in sorted(params)])
class FromCache(MapperOption):
"""Specifies that a Query should load results from a cache."""