summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-12-03 19:50:01 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-12-03 19:50:01 -0500
commit699146086df8fd8778582a03267f8f28c5cdad7a (patch)
tree80118f3c361508f0aab5f10995f96870bdc8cc5d /lib/sqlalchemy/sql/expression.py
parentd628967ad21ab103f3c2766728a5b18923348795 (diff)
downloadsqlalchemy-699146086df8fd8778582a03267f8f28c5cdad7a.tar.gz
- [bug] Fixed bug whereby column_property() created
against ORM-level column could be treated as a distinct entity when producing certain kinds of joined-inh joins. [ticket:2316] - [bug] related to [ticket:2316], made some adjustments to the change from [ticket:2261] regarding the "from" list on a select(). The _froms collection is no longer memoized, as this simplifies various use cases and removes the need for a "warning" if a column is attached to a table after it was already used in an expression - the select() construct will now always produce the correct expression. There's probably no real-world performance hit here; select() objects are almost always made ad-hoc, and systems that wish to optimize the re-use of a select() would be using the "compiled_cache" feature. A hit which would occur when calling select.bind has been reduced, but the vast majority of users shouldn't be using "bound metadata" anyway :).
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r--lib/sqlalchemy/sql/expression.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index ce853fd22..c333bb639 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -3905,12 +3905,6 @@ class ColumnClause(_Immutable, ColumnElement):
def _get_table(self):
return self.__dict__['table']
def _set_table(self, table):
- if '_from_objects' in self.__dict__:
- util.warn("%s being associated with %s object after "
- "the %s has already been used in a SQL "
- "generation; previously generated "
- "constructs may contain stale state." %
- (type(table), type(self), type(self)))
self._memoized_property.expire_instance(self)
self.__dict__['table'] = table
table = property(_get_table, _set_table)
@@ -4502,12 +4496,15 @@ class Select(_SelectBase):
_SelectBase.__init__(self, **kwargs)
- @_memoized_property
+ @property
def _froms(self):
+ # would love to cache this,
+ # but there's just enough edge cases, particularly now that
+ # declarative encourages construction of SQL expressions
+ # without tables present, to just regen this each time.
froms = []
seen = set()
translate = self._from_cloned
-
def add(items):
for item in items:
if translate and item in translate:
@@ -4613,7 +4610,8 @@ class Select(_SelectBase):
actually be rendered.
"""
- return self._froms + list(_from_objects(*self._froms))
+ froms = self._froms
+ return froms + list(_from_objects(*froms))
@property
def inner_columns(self):
@@ -5026,14 +5024,15 @@ class Select(_SelectBase):
def bind(self):
if self._bind:
return self._bind
- if not self._froms:
+ froms = self._froms
+ if not froms:
for c in self._raw_columns:
e = c.bind
if e:
self._bind = e
return e
else:
- e = list(self._froms)[0].bind
+ e = list(froms)[0].bind
if e:
self._bind = e
return e