summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/session.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-08-05 04:49:57 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-08-05 04:49:57 +0000
commitba9380ef28871b2274ab0bab75e5efddf2ced467 (patch)
treea69613dca1434c25ed2b8bfb877338206213f4e4 /lib/sqlalchemy/orm/session.py
parentc813fe1678c4edbce32f0652353ed70f0a14566f (diff)
parent14fdd6260a578488bdad95b738ea6af5c2fcd13c (diff)
downloadsqlalchemy-ba9380ef28871b2274ab0bab75e5efddf2ced467.tar.gz
Merge "Establish future behavior for Session cascade backrefs, bind"
Diffstat (limited to 'lib/sqlalchemy/orm/session.py')
-rw-r--r--lib/sqlalchemy/orm/session.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 01163b8d4..25aedd52d 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1937,16 +1937,34 @@ class Session(_SessionClassMethods):
# now we are in legacy territory. looking for "bind" on tables
# that are via bound metadata. this goes away in 2.0.
+
+ future_msg = ""
+ future_code = ""
+
if mapper and clause is None:
clause = mapper.persist_selectable
if clause is not None:
if clause.bind:
- return clause.bind
+ if self.future:
+ future_msg = (
+ " A bind was located via legacy bound metadata, but "
+ "since future=True is set on this Session, this "
+ "bind is ignored."
+ )
+ else:
+ return clause.bind
if mapper:
if mapper.persist_selectable.bind:
- return mapper.persist_selectable.bind
+ if self.future:
+ future_msg = (
+ " A bind was located via legacy bound metadata, but "
+ "since future=True is set on this Session, this "
+ "bind is ignored."
+ )
+ else:
+ return mapper.persist_selectable.bind
context = []
if mapper is not None:
@@ -1955,8 +1973,9 @@ class Session(_SessionClassMethods):
context.append("SQL expression")
raise sa_exc.UnboundExecutionError(
- "Could not locate a bind configured on %s or this Session"
- % (", ".join(context))
+ "Could not locate a bind configured on %s or this Session.%s"
+ % (", ".join(context), future_msg),
+ code=future_code,
)
def query(self, *entities, **kwargs):