This solution seems to work in my context 

Thanks
Gio

Am Mittwoch, 8. Mai 2013 16:18:31 UTC+2 schrieb Michael Bayer:
>
> from sqlalchemy.sql import column, tuple_
>
> a, b = column('a'), column('b')
>
> print tuple_(a, b).op("OVERLAPS")(tuple_(1, 2))
>
>
> "(a, b) OVERLAPS (:param_1, :param_2)"
>
>
>
>
> On May 8, 2013, at 6:39 AM, gio <giovanni...@auditq.com <javascript:>> 
> wrote:
>
> Hi all
>
> Searching how to solve the 
>
> (start,end).op('OVERLAPS')(,start1,end1)
> Problem with postgres and salqalchemy 0.8
>
> Some hints ?
>
>
> Note:
> _CompareMixin
> is not presen in SQLalchem 0.8
>
>
> Am Freitag, 21. August 2009 09:50:10 UTC+2 schrieb David Bolen:
>>
>> Has anyone generated ORM queries using the OVERLAPS SQL operator that
>> reference columns in the tables in the query?  I've been experimenting
>> with various approaches and can't seem to cleanly get the column names
>> (with their appropriate alias based on the rest of the query) into the
>> overlaps clause.
>>
>> I'm basically issuing an ORM query and want to check that the date
>> range given by two columns in one of the objects being queried is
>> overlaps with a computed date range.  In some cases the object whose
>> columns I am checking is the primary target of the query whereas in
>> others it's a joined class.
>>
>> I found an older post from March where Michael suggested the form
>>
>>     <somexpression>.op('OVERLAPS', <someotherexpression>)
>>
>> but I can't figure out how to apply that, and in particular what sort
>> of expression will produce a tuple at the SQL layer, yet still support
>> the "op" method?  Namely the output needs to be of the form:
>>
>>     (start, stop) OVERLAPS (start, stop)
>>
>> So I figured I'd try straight text, and was attempting something like:
>>
>>     query(MappedClass).
>>       filter('(:c_start, :c_end) overlaps (:start, :end)').
>>       params(c_start=MappedClass.start_col, c_end=MappedClass.end_col,
>>              start=<datetimevalue>, end=<datetimevalue>)
>>
>> but I'm having trouble identifying an appropriate value for the
>> c_start/c_end params to generate the column names in the resulting
>> SQL.  The above gives can't adapt the InstrumentedAttribute references
>> in the params.
>>
>> In the meantime I can fall back to a pure textual filter which will
>> have to assume how the mapped class will be aliased, but that feels
>> fragile and it'd be nice if I could let SQLAlchemy generate the column
>> names somehow.  I get the feeling though that OVERLAPS is a bit
>> unusual in terms of the necessary support since it has non-scalar left
>> and right values for the operator.
>>
>> Thanks for any help.
>>
>> -- David
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
> -- 
> 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+...@googlegroups.com <javascript:>.
> To post to this group, send email to sqlal...@googlegroups.com<javascript:>
> .
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
>

-- 
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to