I'm having some issues when I try to put an identically named bind parameter into two selects, and then union them.
from sqlalchemy import *
meta = DynamicMetaData()
# I have these two tables:
users = Table('users', meta,
Column('id', Integer, primary_key = True),
Column('user_name', String(16) ))
friendship = Table('friendship', meta,
Column('user_id', Integer, ForeignKey(' users.id'), primary_key=True),
Column('friend_id', Integer, ForeignKey('users.id'), primary_key=True))
# the selects
s1 = select([friendship.c.friend_id], and_(users.c.id==friendship.c.user_id , users.c.id==bindparam('id')))
s2 = select([friendship.c.user_id], and_(users.c.id==friendship.c.friend_id, users.c.id==bindparam('id')))
u = union(s1, s2)
u.execute(id=1)
####
This results in the following database interaction:
[2006-10-04 12:51:50,421] [engine]: SELECT friendship.friend_id
FROM friendship, users
WHERE users.id = friendship.user_id AND users.id = ? UNION SELECT friendship.use
r_id
FROM friendship, users
WHERE users.id = friendship.friend_id AND users.id = ?
[2006-10-04 12:51:50,437] [engine]: [1, None]
####
The bindparam id is being passed to just one of the selects when I execute. Any ideas? I've tried creating a single instance of the bindparam and putting it in both selects, but that results in an incorrect number of bindings being supplied when I execute the statement.
-Michael
------------------------------------------------------------------------- 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