On Oct 15, 2013, at 11:35 PM, Michael Bayer <[email protected]> wrote:

> 
> On Oct 15, 2013, at 3:22 PM, Chris Withers <[email protected]> wrote:
> 
>> Hi All,
>> 
>> How would I express the following postgresql query in SQLAlchemy?
>> 
>> select * from observation where '[2013-01-01,2013-01-03)'::tsrange @> period;
>> 
>> I know how to do the right operand:
>> 
>> session.query(Observation).filter(Observation.period.contains(Range(...)))
>> 
>> ...but not the other way round.
>> 
>> What am I missing?
> 
> 
> well you'd use literal() around it, though I guess we don't coerce that type 
> which would give you the operators, so maybe type_coerce:
> 
> type_coerce(some_range(...), NUMRANGE).contains(other)

eh maybe literal() , actually:

literal(some_range(...), type_=NUMRANGE).contains(other)


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to