On Jul 31, 2006, at 6:49 PM, Kai wrote:
> After removing that line, the for loop only removes all order_by
> clauses
> from the *selects array. Thats nice for the optimizer, but I'm
> pretty sure
> that it can be removed too.
>
> 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:
from sqlalchemy import *
engine = create_engine('sqlite://', echo=True)
meta = BoundMetaData(engine)
table = Table('sometable', meta,
Column('id', Integer, primary_key=True),
Column('foo', String(20)))
meta.create_all()
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 'SELECT sometable.id,
sometable.foo \nFROM sometable ORDER BY sometable.foo UNION SELECT
sometable.id, sometable.foo \nFROM sometable ORDER BY sometable.id' []
similarly, ive tried putting parenthesis in there too and sqlite
doesnt seem to like that either.
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users