diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-06-26 13:00:58 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-06-26 13:00:58 -0400 |
| commit | e4d9679ccfc06e661a3281b40e6d684695b74783 (patch) | |
| tree | f429650397ad8d4842d7838f95c6f40dbf9c9a57 /examples/sharding | |
| parent | dc5d56d219262a766293df0aedd422550d851be8 (diff) | |
| download | sqlalchemy-e4d9679ccfc06e661a3281b40e6d684695b74783.tar.gz | |
- Fixed the attribute shard example to check
for bind param callable correctly in 0.7
style.
Diffstat (limited to 'examples/sharding')
| -rw-r--r-- | examples/sharding/attribute_shard.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py index b36b8a01d..5831d7ee3 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 |
