Re: [Sqlalchemy-tickets] [sqlalchemy] #2932: textasfrom compatibility with columns, query
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2014-02-11 00:23:54
|
#2932: textasfrom compatibility with columns, query
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: highest | Milestone: 0.9.3
Component: sql | Severity: major - 1-3 hours
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: reopened => closed
* resolution: => fixed
* status_field: in progress => completed/closed
Comment:
rbf934018a52b4fe4c43745f is as far as we can go. I tried also doing this:
{{{
#!python
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -274,7 +274,7 @@ class _CompileLabel(visitors.Visitable):
__slots__ = 'element', 'name'
def __init__(self, col, name, alt_names=()):
- self.element = col
+ self.element = self._element = col
self.name = name
self._alt_names = (col,) + alt_names
@@ -511,7 +511,7 @@ class SQLCompiler(Compiled):
add_to_result_map(
labelname,
label.name,
- (label, labelname, ) + label._alt_names,
+ (label, labelname, label._element) +
label._alt_names,
label.type
)
}}}
which allows the idea of `text("select A as
X").columns(column("A").label("X"))`, but we get into naming conflicts
there, and test.sql.test_query's tests for label conflicts does find one.
The issue is if there are multiple columns named "A" with different
labels, we can't do it as above. It's possible we could do something
specific for `TextAsFrom`, but it would have to correct for the same
column() present twice perhaps. I don't think it's a need right now.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2932#comment:8>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|