On Fri, Aug 04, 2006 at 07:26:43PM -0400, Michael Bayer wrote:
> 
> >class CompoundSelect(SelectBaseMixin, FromClause):
> >    def __init__(self, keyword, *selects, **kwargs):
> >        SelectBaseMixin.__init__(self)
> >        self.keyword = keyword
> >        self.selects = selects
> >        self.use_labels = kwargs.pop('use_labels', False)
> >        self.parens = kwargs.pop('parens', False)
> >        self.correlate = kwargs.pop('correlate', False)
> >        self.for_update = kwargs.pop('for_update', False)
> >        #for s in self.selects:
> >        #    s.group_by(None)
> >        #    s.order_by(None)
> >        self.group_by(*kwargs.get('group_by', [None]))
> >        self.order_by(*kwargs.get('order_by', [None]))
> >        self._col_map = {}
> 
> 
> if I do that, then this test in sqlite fails:
..
> s1 = table.select(order_by=[table.c.foo])
> s2 = table.select(order_by=[table.c.id])
> s3 = s1.union(s2)
> s3.execute()
> 
> returns:
> 
> sqlalchemy.exceptions.SQLError: (OperationalError) ORDER BY clause  
> should come after UNION not before 

Hi Michael,

Your test tests correctly, an order by shouldnt come inside a subselect, as
it doesn't matter anyway, except for a few optimizings. So yes, in the union
the order by should be removed from the given selectable. Though perhaps it
should instantiate that selectable so that it doesn't remove the order by
from the original query, but that is another story. I think the union()
problem is solved for me.

Cheers,

Kai
-- 
begin 600 .signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to