On Apr 21, 2010, at 4:08 PM, Rhett Garber wrote: > On Wed, Apr 21, 2010 at 6:35 AM, Michael Bayer <[email protected]> > wrote: >> Rhett Garber wrote: >>> This would be much easier, I could potentially be what we go with. I >>> think this is similar to my 'original implementation' >>> I just found the syntax to be a bit bothersome since the person >>> creating the table has to know they are creating two >>> columns... or not using declarative. These ids are (and foreign keys) >>> mean you'll be doing something like this multiple >>> times on every table in our system, so I want it to be a streamline >>> and foolproof as possible. >> >> It hasn't gotten across to me what the "two columns" version of this is. >> an illustration of the table schema and mappings for that might make it >> clearer what you are attempting. > > Oh right, sorry: > > class Advertiser(Base): > __tablename__ = "advertiser" > id, _id = build_id_column('id', primary_key=True) > salesperson_id, _salesperson_id = > build_id_column('salesperson_id', foreign_key=ForeignKey("%s.id" % > Salesperson.__tablename__)) > salesperson, _salesperson = build_relation(Salesperson)
sorry, that mapping doesn't really make any sense to me. > Where these build_* functions are returning tuple where the first > element is a synonym for the second, which some extra descriptor stuff > on it > to do the obfuscation. right but, you don't define synonyms that way. Its best to stick with the methods in the documentation. > > I'm not quite sure I have my head around what's different than your > solution, except this is trying to use declarative syntax. > Perhaps that's the problem. synonyms with declarative are described in the declarative docs: http://www.sqlalchemy.org/docs/reference/ext/declarative.html?highlight=declarative#defining-synonyms -- 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.
