From: Mike Bayer Date: Sun, 26 Jun 2011 17:00:58 +0000 (-0400) Subject: - Fixed the attribute shard example to check X-Git-Tag: rel_0_7_2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4d9679ccfc06e661a3281b40e6d684695b74783;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed the attribute shard example to check for bind param callable correctly in 0.7 style. --- diff --git a/CHANGES b/CHANGES index d8f71bbaee..c7695f488e 100644 --- a/CHANGES +++ b/CHANGES @@ -68,6 +68,10 @@ CHANGES correct foreign key in a multi-level inheritance situation. + - Fixed the attribute shard example to check + for bind param callable correctly in 0.7 + style. + 0.7.1 ===== - general diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py index b36b8a01db..5831d7ee39 100644 --- a/examples/sharding/attribute_shard.py +++ b/examples/sharding/attribute_shard.py @@ -160,17 +160,19 @@ def _get_query_comparisons(query): comparisons = [] def visit_bindparam(bind): - # visit a bind parameter. Below we ensure - # that we get the value whether it was specified - # as part of query.params(), or is directly embedded - # in the bind's "value" attribute. - value = query._params.get(bind.key, bind.value) - - # some ORM functions place the bind's value as a - # callable for deferred evaulation. Get that - # actual value here. - if callable(value): - value = value() + # visit a bind parameter. + + # check in _params for it first + if bind.key in query._params: + value = query._params[bind.key] + elif bind.callable: + # some ORM functions (lazy loading) + # place the bind's value as a + # callable for deferred evaulation. + value = bind.callable() + else: + # just use .value + value = bind.value binds[bind] = value