it still is needed if you explicitly need an alias() of your SELECT
statement. joining to it, embedding it within aliased().haven't
figured out yet if there's some way to make it "automatic" in all
cases or if thats appropriate.
also more controverially im thinking of adding a .c. to Q
> im committing something that will make that exact phrase work (its in
> rev 5734). using a released version of SQLA, for now say
> id.in_(query.statement).
I took at look at those changes and they look awesome! If I understand
the changes correctly, however, then I wonder what purpose subquer
On Mon, Jan 26, 2009 at 7:05 PM, Michael Bayer wrote:
>
>
> On Jan 26, 2009, at 7:31 PM, Jon Nelson wrote:
>
>>
>> I assumed it was a bug due to the presence of a python-style string
>> substitution.
>>
>> ...
>>
>>> another option is
>>> sess.query(Account).filter(Account.id.in_(your subquery)).
On Jan 26, 2009, at 7:31 PM, Jon Nelson wrote:
>
> I assumed it was a bug due to the presence of a python-style string
> substitution.
>
> ...
>
>> another option is
>> sess.query(Account).filter(Account.id.in_(your subquery)).
>
> When I do it that way, I get crazy SQL and an error. Using
> Acc
I assumed it was a bug due to the presence of a python-style string
substitution.
...
> another option is
> sess.query(Account).filter(Account.id.in_(your subquery)).
When I do it that way, I get crazy SQL and an error. Using
Account.accountid to shorten the SQL:
>>> q0 =
>>> s.query(Account.
On Jan 26, 2009, at 6:21 PM, Jon Nelson wrote:
>
> If I try that, I get:
>
> sqlalchemy.exc.ProgrammingError: (ProgrammingError) aggregates not
> allowed in WHERE clause
>
> The SQL generated is:
>
> SELECT account.accountid AS account_accountid
> FROM account
> JOIN userinfo ON account.accounti
On Mon, Jan 26, 2009 at 5:21 PM, Jon Nelson wrote:
...
If I start with this subquery:
> q0 = s.query(Account.accountid,
> sa.func.count(User.userid).label('user_count'))
> .join(Account.users)
> .group_by(Account.accountid)
> .having(sa.func.count(User.userid)>1)
> .subquery
If I try that, I get:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) aggregates not
allowed in WHERE clause
The SQL generated is:
SELECT account.accountid AS account_accountid
FROM account
JOIN userinfo ON account.accountid = userinfo.accountid
WHERE count(userinfo.userid) > %(count_1)s
GR
I think you have to use group by with a count(). Something like
Account.query.join(Account.users).group_by(Account.id).filter(func.count(User.id)
> 1)
On Mon, Jan 26, 2009 at 12:59 PM, Jon Nelson wrote:
>
> Let's assume I have a 1:many relationship between Accounts and Users.
>
> What I want (f