diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-08 18:37:47 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-08 18:37:47 +0000 |
| commit | 9deea462a5188c2d9faa93d493abb4042493b5f9 (patch) | |
| tree | 31ffae2ce44b83420d7394f9f619934c8348ef49 /lib/sqlalchemy/orm | |
| parent | acafbca090ef2eba809da562b3690c17497f0368 (diff) | |
| download | sqlalchemy-9deea462a5188c2d9faa93d493abb4042493b5f9.tar.gz | |
- Query called in the context of an expression will render
disambiguating labels in all cases. Note that this does
not apply to the existing .statement and .subquery()
accessor/method, which still honors the .with_labels()
setting that defaults to False.
- Query.union() retains disambiguating labels within the
returned statement, thus avoiding various SQL composition
errors which can result from column name conflicts.
[ticket:1676]
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index fff7fb9d9..ed5535151 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -355,7 +355,13 @@ class Query(object): @property def statement(self): - """The full SELECT statement represented by this Query.""" + """The full SELECT statement represented by this Query. + + The statement by default will not have disambiguating labels + applied to the construct unless with_labels(True) is called + first. + + """ return self._compile_context(labels=self._with_labels).\ statement._annotate({'_halt_adapt': True}) @@ -365,11 +371,15 @@ class Query(object): Eager JOIN generation within the query is disabled. + The statement by default will not have disambiguating labels + applied to the construct unless with_labels(True) is called + first. + """ return self.enable_eagerloads(False).statement.alias() def __clause_element__(self): - return self.enable_eagerloads(False).statement + return self.enable_eagerloads(False).with_labels().statement @_generative() def enable_eagerloads(self, value): |
