[Sqlalchemy-tickets] [sqlalchemy] #2796: Labeled subqueries
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-08-06 09:13:21
|
#2796: Labeled subqueries
----------------------+-----------------------------------------
Reporter: kvesteri | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone:
Component: sql | Severity: no triage selected yet
Keywords: | Progress State: awaiting triage
----------------------+-----------------------------------------
Atleast PostgreSQL requires aliases for all subqueries. I'm trying to
formulate the following query into SQLAlchemy expression construct:
{{{#!SQL
SELECT count(DISTINCT :param_1) AS count_1
FROM (
SELECT company.id AS id
FROM company
) AS company_ids
}}}
Now assume Company is any declarative class containing only one column
(id).
{{{#!python
company_ids = db.select([Company.id], from_obj=Company.__table__)
print db.session.execute(db.select([db.func.count(db.distinct('id'))],
from_obj=company_ids.label('company_ids')))
}}}
It gives me the following exception:
AttributeError: Neither 'Label' object nor 'Comparator' object has an
attribute '_hide_froms'
I know the query I provided here makes a little sense (it could be
simplified to a query without subqueries). I provided it as an example of
failing scenario.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2796>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|