Hi,
Could you shed some light on what I might be doing incorrectly? I have this 
text() SELECT * query on top of a one-column sub-query and in the result, I 
am not getting that column name.

```
stmt = text('select "FirstName", from "Customer"')
stmt = select('*').select_from(stmt.columns().alias())
print(stmt)

SELECT *
FROM (select "FirstName",  from "Customer") AS anon_1
```

This is works, but produces incorrect column name in the output:
```
res = engine.execute(stmt)
keys = res.fetchall()[0].keys()
print(keys)

['*']
```

But when the subquery has two columns, then it works as expected:
```
stmt = text('select "FirstName", "LastName" from "Customer"')
stmt = select('*').select_from(stmt.columns().alias())
res = engine.execute(stmt)
keys = res.fetchall()[0].keys()
print(keys)

['FirstName', 'LastName']
```
So, is there a better way to wrap text query? Why column name is lost in 
the first case? Is it a bug?

Tested on 1.3.20 and 1.2.19

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/c0be052d-1c20-49d1-a73d-875b4a7afef9n%40googlegroups.com.

Reply via email to