Hello Mike,

This simple test illustrate the problem :

>>> from sqlalchemy import func
>>> print 'foo' == func.any('bar')
any(:any) = :a_1

it should be :a_1 = any(:any)

If you look at the PostgreSQL documentation,
http://www.postgresql.org/docs/8.2/static/functions-comparisons.html#AEN14105 
the syntax is: 
expression operator ANY (array expression)

and not :
ANY (array expression) expression operator

Note the ANY can also be used with subselect (so it's not specific to
the PostgreSQL array type) :
http://www.postgresql.org/docs/8.2/static/functions-subquery.html#AEN13959

expression operator ANY (subquery)

and in this case it's also incorrect :

>>> print 'foo' == func.any(select)
any(:any) = :a_1

(again it should be :a_1 = any(:any))

Regards,
Julien

On Tue, 2007-03-27 at 12:13 -0400, Michael Bayer wrote:
> also we dont really have any direct support for python array types,  
> which seemed to be an element of your test.  can you try a basic func  
> test without an array type being used ?
> 
> 
> 
> On Mar 27, 2007, at 10:58 AM, Julien Cigar wrote:
> 
> >
> > The query is rather complicated: http://rafb.net/p/qyx3vA47.html
> > The problem is at line 95 (the FIXME)
> >
> > Thanks
> >
> > Michael Bayer wrote:
> >> On Mar 27, 2007, at 10:00 AM, Julien Cigar wrote:
> >>
> >>
> >>> Hello,
> >>>
> >>> I'm using SQLAlchemy 0.3.5, and it seems that the func() output is
> >>> broken with some functions.
> >>> I use the ANY function of PostgreSQL with something like :
> >>> func.any(q.c.habitats)==filter_habitat
> >>>
> >>> SQLAlchemy translates this in:
> >>> WHERE any(habitats) = %(any)s, which is incorrect.
> >>>
> >>
> >>
> >>> For example:
> >>>
> >>> the result should be :
> >>> iasdev=> select true as result where 'abc' = ANY(array['abc',  
> >>> 'def']);
> >>>  result
> >>> --------
> >>>  t
> >>>
> >>> where SQLAlchemy generates the query as :
> >>>
> >>> iasdev=> select true as result where ANY(array['abc', 'def']) =  
> >>> 'abc';
> >>> ERROR:  syntax error at or near "ANY" at character 29
> >>> LINE 1: select true as result where ANY(array['abc', 'def']) =
> >>> 'abc'...
> >>>
> >>> Is this a bug ? (or maybe it's possible to keep the order...) ?
> >>>
> >>
> >> can i have some complete code examples please ?  i dont understand
> >> how your snippet would produce a full SELECT statement.  the phrase
> >> youve shown me translates exactly as specified, assuming
> >> "filter_habitat" is ia non ClauseElement::
> >>
> >>    func.any(q.c.habitats)==filter_habitat
> >>
> >>    should be:
> >>
> >>    any(habitats) = %(any)s
> >>
> >>
> >>
> >>
> >>>
> >>
> >
> >
> > -- 
> > Julien Cigar
> > Belgian Biodiversity Platform
> > http://www.biodiversity.be
> > Universit� Libre de Bruxelles (ULB)
> > Campus de la Plaine CP 257
> > B�timent NO, Bureau 4 N4 115C (Niveau 4)
> > Boulevard du Triomphe, entr�e ULB 2
> > B-1050 Bruxelles
> > office: [EMAIL PROTECTED]
> > home: [EMAIL PROTECTED]
> > biobel reference: http://biobel.biodiversity.be/biobel/person/show/471
> >
> >
> > >
> 
> 
> > 
-- 
Julien Cigar
Belgian Biodiversity Platform
http://www.biodiversity.be
Universit� Libre de Bruxelles
Campus de la Plaine CP 257
B�timent NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entr�e ULB 2
B-1050 Bruxelles
mail: [EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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