summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-12-09 23:27:04 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-12-09 23:27:04 +0000
commit5cdb942791b9aeb63d02680c712d1afc104606b0 (patch)
treeb4a0d319063136e299bf4a01399febc767c10186 /lib/sqlalchemy/sql
parent7cbfbba9496fc41c21390aad8d8731c45fbacbce (diff)
downloadsqlalchemy-5cdb942791b9aeb63d02680c712d1afc104606b0.tar.gz
- Query.select_from() now replaces all existing FROM criterion with
the given argument; the previous behavior of constructing a list of FROM clauses was generally not useful as is required filter() calls to create join criterion, and new tables introduced within filter() already add themselves to the FROM clause. The new behavior allows not just joins from the main table, but select statements as well. Filter criterion, order bys, eager load clauses will be "aliased" against the given statement.
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/compiler.py2
-rw-r--r--lib/sqlalchemy/sql/expression.py16
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 3af8f97ca..30b4089d3 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -36,7 +36,7 @@ ILLEGAL_INITIAL_CHARACTERS = re.compile(r'[0-9$]')
BIND_PARAMS = re.compile(r'(?<![:\w\$\x5c]):([\w\$]+)(?![:\w\$])', re.UNICODE)
BIND_PARAMS_ESC = re.compile(r'\x5c(:[\w\$]+)(?![:\w\$])', re.UNICODE)
-ANONYMOUS_LABEL = re.compile(r'{ANON (-?\d+) (.*)}')
+ANONYMOUS_LABEL = re.compile(r'{ANON (-?\d+) (.*?)}')
BIND_TEMPLATES = {
'pyformat':"%%(%(name)s)s",
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index ea8e067cd..7caee3314 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1611,7 +1611,11 @@ class FromClause(Selectable):
return None
else:
raise exceptions.InvalidRequestError("Column instance '%s' is not directly present within selectable '%s'" % (str(column), column.table.description))
-
+
+ # dont dig around if the column is locally present
+ if self.c.contains_column(column):
+ return column
+
col, intersect = None, None
target_set = column.proxy_set
for c in self.c + [self.oid_column]:
@@ -2442,10 +2446,12 @@ class Alias(FromClause):
baseselectable = baseselectable.selectable
self.original = baseselectable
- def get_children(self, **kwargs):
- for c in self.c:
- yield c
- yield self.selectable
+ def get_children(self, column_collections=True, aliased_selectables=True, **kwargs):
+ if column_collections:
+ for c in self.c:
+ yield c
+ if aliased_selectables:
+ yield self.selectable
def _get_from_objects(self, **modifiers):
return [self]