yah a little bug there, exists() was degined to be used in WHERE criterion but not as a standalone. theres a tweak in r2358 where it will suppress its "FROM" list in a select the way you were trying to do.
On Feb 23, 10:25 am, Manlio Perillo <[EMAIL PROTECTED]> wrote: > Hi. > > I'm having problems with the exists clause. > > Here is the code: > > from sqlalchemy import * > > db = create_engine('sqlite:///', echo=True) > metadata = BoundMetaData(db) > > test = Table( > 'test', metadata, > Column('id', Integer, primary_key=True), > Column('x', String), > Column('y', String) > ) > > metadata.create_all() > try: > conn = db.contextual_connect() > > # i = test.insert() > # conn.execute(i, x='x', y='z') > > # Test if select works without a from clause > query = select([text('1 + 1')]) > print conn.execute(query).scalar() > > query = select( > [exists( > [test.c.id], > and_( > test.c.x == 'x', > test.c.y == 'y' > ) > )] > ) > print conn.execute(query).scalar() > finally: > metadata.drop_all() > > The generated query is: > > SELECT EXISTS (SELECT test.id AS id > FROM test > WHERE test.x = ? AND test.y = ?) > FROM (SELECT test.id AS id > FROM test > WHERE test.x = ? AND test.y = ?) > > This is wrong (it works on SQLite but Postgres raises an error). > I have tried to add a from_obj=[], but it does not works. > > Thanks and regards Manlio Perillo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---