summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/mapper.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
-rw-r--r--lib/sqlalchemy/orm/mapper.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 13151f232..a9dad9176 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -163,11 +163,10 @@ class Mapper(object):
self.with_polymorphic = None
if isinstance(self.local_table, expression._SelectBaseMixin):
- util.warn("mapper %s creating an alias for the given "
- "selectable. References to the original selectable "
- "may be misinterpreted by queries, polymorphic_on, etc. "
- " Consider passing an explicit selectable.alias() construct instead." % self)
- self.local_table = self.local_table.alias()
+ raise sa_exc.InvalidRequestError(
+ "When mapping against a select() construct, map against an alias() of the construct instead."
+ "This because several databases don't allow a SELECT from a subquery that does not have an alias."
+ )
if self.with_polymorphic and isinstance(self.with_polymorphic[1], expression._SelectBaseMixin):
self.with_polymorphic = (self.with_polymorphic[0], self.with_polymorphic[1].alias())