working excellently now... thank you much! On 8/22/06, Michael Bayer <[EMAIL PROTECTED]> wrote: > ok well, that was quite small so rev 1818 fixes it. however i > havent gone too deeply into testing beyond your example so keep me > posted of how much futher your program gets. > > On Aug 22, 2006, at 7:45 PM, Pete Taylor wrote: > > > Hi all, > > I'm fairly new to SA, and apologize if this has been answered > > elsewhere... I've dug through old mailing lists, but can't find > > anything, and haven't seen this referenced in the docs. > > > > I have a set of table definitions that are using the following > > construct for a foreign key: > > Column("other_table_id", Integer, ForeignKey("other_table.id"), > > key="otherId") > > > > I can't see any particular reason for this not to work, but it > > doesn't. It throws a KeyError on the column name when it hits the > > column that contains the ForeignKey statement. I know it worked in > > the past, but I inherited the code, and I'm not sure at what SA > > version it did work (I can install a few older eggs to find out, if > > that will help). What's strange though is that if I remove the > > keyword arg "key", it runs just fine. I've built a small test case > > for it, and included it below. > > > > Thanks for any help! > > Pete > > > > ############################################################ > > from sqlalchemy import * > > > > engine = create_engine('sqlite:///:memory:') > > metadata = BoundMetaData(engine) > > > > > > def main(): > > test_table_one = Table('test_table_one', metadata, > > Column('legacy_test_id', Integer, primary_key=True, key="id"), > > Column('test_column_one', String(50)), > > ) > > > > try: > > test_table_two = Table('test_table_two', metadata, > > Column('id', Integer, primary_key=True), > > Column('t_one_id', Integer, > > ForeignKey('test_table_one.id'), key="tid"), > > Column('test_column_two', String(50)), > > ) > > except Exception, e: > > print "Test Table Two build with explicit key name on FK > > failed" > > print "Exception was on %s " % e > > > > try: > > test_table_two = Table('test_table_two', metadata, > > Column('id', Integer, primary_key=True), > > Column('t_one_id', Integer, ForeignKey > > ('test_table_one.id')), > > Column('test_column_two', String(50)), > > redefine=True > > ) > > except Exception, e: > > print "Test Table Two build without explicit key name on FK > > failed" > > print "Exception was on %s " % e > > > > else: > > print "Test Table Two build without explicit key name on FK > > succedded" > > > > if __name__=="__main__": > > main() > > > > ################################################################# > > > > -- > > "All guilt is relative, loyalty counts, and never let your conscience > > be your guide." > > - Lucas Buck, American Gothic > > > > ---------------------------------------------------------------------- > > --- > > Using Tomcat but need to do more? Need to support web services, > > security? > > Get stuff done quickly with pre-integrated technology to make your > > job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > > Geronimo > > http://sel.as-us.falkag.net/sel? > > cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > Sqlalchemy-users mailing list > > Sqlalchemy-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users > >
-- "All guilt is relative, loyalty counts, and never let your conscience be your guide." - Lucas Buck, American Gothic ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users