[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?
On Mar 28, 2008, at 8:06 AM, Julien wrote: # Problem is here # func.count( select( [sp.c.id], sp.c.site_id.in_( select( [model.t_sites.c.id], and_( model.t_sites.c.latitude != None, model.t_sites.c.longitude != None, ) ) ) ) ).label('specimen_filtered_georeferenced'), ## I think you want to convert the select to a scalar, i.e. count(myselect.as_scalar()). --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?
It doesn't work because more than one row are returned by the subquery used in the expression ... On Fri, 2008-03-28 at 09:30 -0400, Michael Bayer wrote: On Mar 28, 2008, at 8:06 AM, Julien wrote: # Problem is here # func.count( select( [sp.c.id], sp.c.site_id.in_( select( [model.t_sites.c.id], and_( model.t_sites.c.latitude != None, model.t_sites.c.longitude != None, ) ) ) ) ).label('specimen_filtered_georeferenced'), ## I think you want to convert the select to a scalar, i.e. count(myselect.as_scalar()). -- 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 Mail: [EMAIL PROTECTED] @biobel: http://biobel.biodiversity.be/person/show/471 Tel : 02 650 57 52 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?
In the documentation I found Note that from objects are automatically located within the columns and whereclause ClauseElements for the select() statement. It is precisely the thing I do not want to.. no way to disable it .. ? Thanks, Julien On Fri, 2008-03-28 at 09:30 -0400, Michael Bayer wrote: On Mar 28, 2008, at 8:06 AM, Julien wrote: # Problem is here # func.count( select( [sp.c.id], sp.c.site_id.in_( select( [model.t_sites.c.id], and_( model.t_sites.c.latitude != None, model.t_sites.c.longitude != None, ) ) ) ) ).label('specimen_filtered_georeferenced'), ## I think you want to convert the select to a scalar, i.e. count(myselect.as_scalar()). -- 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 Mail: [EMAIL PROTECTED] @biobel: http://biobel.biodiversity.be/person/show/471 Tel : 02 650 57 52 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?
On Mar 28, 2008, at 1:36 PM, Julien wrote: in fact all the problem is that I can't generate the following query: SELECT xx.yy, (SELECT xx.yy WHERE cond) FROM foobar xx; where xx.yy are the same columns SQLAlchemy generates : SELECT xx.yy, (SELECT xx.yy FROM foobar xx WHERE cond) FROM foobar xx; This feature has been added in r4366 (it really means we no longer check for over correlation): t = table('t', column('a'), column('b')) s = select([t.c.a]).where(t.c.a==1).correlate(t).as_scalar() s2 = select([t.c.a, s]) self.assert_compile(s2, SELECT t.a, (SELECT t.a WHERE t.a = :t_a_1) AS anon_1 FROM t) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---