summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-02 11:06:08 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-02 11:06:08 -0500
commit29de1077b35fb264f4b1727bd1f4987644ff52b7 (patch)
treebe0c3283a6447f316fcf44b6c1945bead922ec89 /lib/sqlalchemy
parent5b0919f3f5c7678c587858a47e38acd4a5b82f25 (diff)
downloadsqlalchemy-29de1077b35fb264f4b1727bd1f4987644ff52b7.tar.gz
- Fixed bug in new :class:`.TextAsFrom` construct where :class:`.Column`-
oriented row lookups were not matching up to the ad-hoc :class:`.ColumnClause` objects that :class:`.TextAsFrom` generates, thereby making it not usable as a target in :meth:`.Query.from_statement`. Also fixed :meth:`.Query.from_statement` mechanics to not mistake a :class:`.TextAsFrom` for a :class:`.Select` construct. This bug is also an 0.9 regression as the :meth:`.Text.columns` method is called to accommodate the :paramref:`.text.typemap` argument. [ticket:2932]
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py1
-rw-r--r--lib/sqlalchemy/sql/elements.py7
-rw-r--r--lib/sqlalchemy/sql/selectable.py6
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 10d635b8d..949c7eff9 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -3471,6 +3471,7 @@ class QueryContext(object):
if query._statement is not None:
if isinstance(query._statement, expression.SelectBase) and \
+ not query._statement._textual and \
not query._statement.use_labels:
self.statement = query._statement.apply_labels()
else:
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index 975cf2d79..cca03851f 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -2920,9 +2920,12 @@ class ColumnClause(Immutable, ColumnElement):
def _compare_name_for_result(self, other):
if self.is_literal or \
- self.table is None or \
+ self.table is None or self.table._textual or \
not hasattr(other, 'proxy_set') or (
- isinstance(other, ColumnClause) and other.is_literal
+ isinstance(other, ColumnClause) and
+ (other.is_literal or
+ other.table is None or
+ other.table._textual)
):
return super(ColumnClause, self).\
_compare_name_for_result(other)
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index 01d617259..bda3d655e 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -137,6 +137,10 @@ class FromClause(Selectable):
named_with_column = False
_hide_froms = []
+ _textual = False
+ """a marker that allows us to easily distinguish a :class:`.TextAsFrom`
+ or similar object from other kinds of :class:`.FromClause` objects."""
+
schema = None
"""Define the 'schema' attribute for this :class:`.FromClause`.
@@ -3046,6 +3050,8 @@ class TextAsFrom(SelectBase):
"""
__visit_name__ = "text_as_from"
+ _textual = True
+
def __init__(self, text, columns):
self.element = text
self.column_args = columns