diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-09-08 19:51:35 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-09-08 19:51:35 +0000 |
commit | fc753a06475c2fa571d09d73d3169b66c272c8d6 (patch) | |
tree | 718820e31a95eadc332277eed905d21ba09a6edf /examples/sharding/attribute_shard.py | |
parent | bf35590e15de3fac7977757d89bc994400f26125 (diff) | |
download | sqlalchemy-fc753a06475c2fa571d09d73d3169b66c272c8d6.tar.gz |
- fixes to ShardedSession to work with deferred columns [ticket:771].
- user-defined shard_chooser() function must accept "clause=None"
argument; this is the ClauseElement passed to session.execute(statement)
and can be used to determine correct shard id (since execute() doesn't
take an instance)
Diffstat (limited to 'examples/sharding/attribute_shard.py')
-rw-r--r-- | examples/sharding/attribute_shard.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/sharding/attribute_shard.py b/examples/sharding/attribute_shard.py index 25da98872..0a9e992a3 100644 --- a/examples/sharding/attribute_shard.py +++ b/examples/sharding/attribute_shard.py @@ -22,6 +22,7 @@ from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.orm.shard import ShardedSession from sqlalchemy.sql import operators +from sqlalchemy import sql import datetime # step 2. databases @@ -107,7 +108,7 @@ shard_lookup = { # note that we need to define conditions for # the WeatherLocation class, as well as our secondary Report class which will # point back to its WeatherLocation via its 'location' attribute. -def shard_chooser(mapper, instance): +def shard_chooser(mapper, instance, clause=None): if isinstance(instance, WeatherLocation): return shard_lookup[instance.continent] else: |