summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/roles.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql/roles.py')
-rw-r--r--lib/sqlalchemy/sql/roles.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/roles.py b/lib/sqlalchemy/sql/roles.py
index 2d3aaf903..053bd7146 100644
--- a/lib/sqlalchemy/sql/roles.py
+++ b/lib/sqlalchemy/sql/roles.py
@@ -100,6 +100,30 @@ class FromClauseRole(ColumnsClauseRole):
raise NotImplementedError()
+class StrictFromClauseRole(FromClauseRole):
+ # does not allow text() or select() objects
+ pass
+
+
+class AnonymizedFromClauseRole(StrictFromClauseRole):
+ # calls .alias() as a post processor
+
+ def _anonymous_fromclause(self, name=None, flat=False):
+ """A synonym for ``.alias()`` that is only present on objects of this
+ role.
+
+ This is an implicit assurance of the target object being part of the
+ role where anonymous aliasing without any warnings is allowed,
+ as opposed to other kinds of SELECT objects that may or may not have
+ an ``.alias()`` method.
+
+ The method is used by the ORM but is currently semi-private to
+ preserve forwards-compatibility.
+
+ """
+ return self.alias(name=name, flat=flat)
+
+
class CoerceTextStatementRole(SQLRole):
_role_name = "Executable SQL, text() construct, or string statement"