diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-10-25 01:40:23 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-10-25 01:40:23 +0000 |
| commit | ed83a844bb143c5b04514800907726e875bf1e82 (patch) | |
| tree | d5f8bea17f22e6c9427b1453c099a660542711d3 /examples/sharding | |
| parent | aa557982fa2518e6d520ce17894093d5ed03c0eb (diff) | |
| download | sqlalchemy-ed83a844bb143c5b04514800907726e875bf1e82.tar.gz | |
- Fixed a slight inaccuracy in the sharding example.
Comparing equivalence of columns in the ORM is best
accomplished using col1.shares_lineage(col2).
[ticket:1491]
Diffstat (limited to 'examples/sharding')
| -rw-r--r-- | examples/sharding/attribute_shard.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py index 2f03a5a34..2ac0c88ff 100644 --- a/examples/sharding/attribute_shard.py +++ b/examples/sharding/attribute_shard.py @@ -134,7 +134,13 @@ def query_chooser(query): # and convert to shard ids class FindContinent(sql.ClauseVisitor): def visit_binary(self, binary): - if binary.left is weather_locations.c.continent: + # "shares_lineage()" returns True if both columns refer to the same + # statement column, adjusting for any annotations present. + # (an annotation is an internal clone of a Column object + # and occur when using ORM-mapped attributes like + # "WeatherLocation.continent"). A simpler comparison, though less accurate, + # would be "binary.left.key == 'continent'". + if binary.left.shares_lineage(weather_locations.c.continent): if binary.operator == operators.eq: ids.append(shard_lookup[binary.right.value]) elif binary.operator == operators.in_op: |
