summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-07-27 11:35:41 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-07-27 11:35:41 -0400
commit95648050cfb2afb5bea8558a6246ed3b5360e7fd (patch)
treefd3fbe0437f798392600605326c6cdfbaac690a6 /lib/sqlalchemy/ext
parentc6b1d24fe71c22e4d2117d084f06df3597671985 (diff)
downloadsqlalchemy-95648050cfb2afb5bea8558a6246ed3b5360e7fd.tar.gz
accommodate plain core textual statements
Fixed issue where the horizontal sharding extension would not correctly accommodate for a plain textual SQL statement passed to :meth:`_orm.Session.execute`. Fixes: #6816 Change-Id: Ie2b71b06d10793443dbd5e1b271c56cbf9431bb3
Diffstat (limited to 'lib/sqlalchemy/ext')
-rw-r--r--lib/sqlalchemy/ext/horizontal_shard.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/ext/horizontal_shard.py b/lib/sqlalchemy/ext/horizontal_shard.py
index 8fb3bf282..5f13ad268 100644
--- a/lib/sqlalchemy/ext/horizontal_shard.py
+++ b/lib/sqlalchemy/ext/horizontal_shard.py
@@ -211,9 +211,11 @@ def execute_and_instances(orm_context):
load_options = active_options = orm_context.load_options
update_options = None
- else:
+ elif orm_context.is_update or orm_context.is_delete:
load_options = None
update_options = active_options = orm_context.update_delete_options
+ else:
+ load_options = update_options = active_options = None
session = orm_context.session
@@ -226,7 +228,7 @@ def execute_and_instances(orm_context):
if orm_context.is_select:
load_options += {"_refresh_identity_token": shard_id}
execution_options["_sa_orm_load_options"] = load_options
- else:
+ elif orm_context.is_update or orm_context.is_delete:
update_options += {"_refresh_identity_token": shard_id}
execution_options["_sa_orm_update_options"] = update_options
@@ -234,7 +236,7 @@ def execute_and_instances(orm_context):
bind_arguments=bind_arguments, execution_options=execution_options
)
- if active_options._refresh_identity_token is not None:
+ if active_options and active_options._refresh_identity_token is not None:
shard_id = active_options._refresh_identity_token
elif "_sa_shard_id" in orm_context.execution_options:
shard_id = orm_context.execution_options["_sa_shard_id"]