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 [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
-~----------~----~----~----~------~----~------~--~---