summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/context.py6
-rw-r--r--lib/sqlalchemy/orm/strategies.py6
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py
index 4e2586203..e834b22e8 100644
--- a/lib/sqlalchemy/orm/context.py
+++ b/lib/sqlalchemy/orm/context.py
@@ -382,6 +382,12 @@ class ORMCompileState(CompileState):
for m in m2.iterate_to_root(): # TODO: redundant ?
self._polymorphic_adapters[m.local_table] = adapter
+ @classmethod
+ def _create_entities_collection(cls, query, legacy):
+ raise NotImplementedError(
+ "this method only works for ORMSelectCompileState"
+ )
+
@sql.base.CompileState.plugin_for("orm", "orm_from_statement")
class ORMFromStatementCompileState(ORMCompileState):
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index 51e81e104..d5f5f8527 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -27,6 +27,7 @@ from .base import _SET_DEFERRED_EXPIRED
from .base import PASSIVE_OFF
from .context import _column_descriptions
from .context import ORMCompileState
+from .context import ORMSelectCompileState
from .context import QueryContext
from .interfaces import LoaderStrategy
from .interfaces import StrategizedProperty
@@ -1791,6 +1792,11 @@ class SubqueryLoader(PostLoader):
# the other post loaders, however we have this here for consistency
elif self._check_recursive_postload(context, path, self.join_depth):
return
+ elif not isinstance(context.compile_state, ORMSelectCompileState):
+ # issue 7505 - subqueryload() in 1.3 and previous would silently
+ # degrade for from_statement() without warning. this behavior
+ # is restored here
+ return
if not self.parent.class_manager[self.key].impl.supports_population:
raise sa_exc.InvalidRequestError(