from sqlalchemy import *
m= MetaData()
trans  =Table( 'trans',   m, Column( 'date', Date),      )
balance=Table( 'balance', m, Column( 'finaldate', Date), )

b = balance.alias('b')
sprev = select( [ func.max( b.c.finaldate)],
             b.c.finaldate < balance.c.finaldate
         )
#correlate is non-generative in 0.3 (ret None) but generative in 0.4
sprev = sprev.correlate( balance) or sprev

r = trans.c.date > func.coalesce( sprev,0 )
     #, as_scalar=True ) with or without all the same



Michael Bayer wrote:
> seems like you might need an as_scalar() on the select object.   
> otherwise send an example.
> 
> 
> On Dec 15, 2007, at 10:06 AM, svilen wrote:
> 
>> seems something about .type vs .type_ or similar:
>>
>> Traceback (most recent call last):
>>  File "tests/convertertest.py", line 152, in
>> test4_balance_trans_via_prev_balance_date_subselect
>>    trans.c.date > func.coalesce( sprev,0 )
>>  File "sqlalchemy/sql/expression.py", line 777, in __call__
>>    return func(*c, **o)
>>  File "sqlalchemy/sql/functions.py", line 12, in __call__
>>    return type.__call__(self, *args, **kwargs)
>>  File "sqlalchemy/sql/functions.py", line 35, in __init__
>>    kwargs.setdefault('type_', _type_from_args(args))
>>  File "sqlalchemy/sql/functions.py", line 75, in _type_from_args
>>    if not isinstance(a.type, sqltypes.NullType):
>> AttributeError: 'Select' object has no attribute 'type'
>>
>>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to