This one time, at band camp, Michael Bayer wrote: >you can hack this with a MapperExtension after_insert rule that sets >the "account_id" field on the Person object after the "account" table >is inserted. a little ugly but probably would work right now.
I'll try the hack now and let you know how it goes. >right now, the mapper youve made considers the primary key of of >Person to be (person.id, account.id). it doenst have any notion of >the join between them being synchronized. Right, that's ok. If you look at the engine dump I posted you'll see that the join failed anyway because the foreign key wasn't being set, so regardless of what the mapper thinks the primary key is, it wasn't going to work. >the pattern youre using is also 99% similar to a plain inheritance >pattern except you have just one class. Well, as mentioned earlier, it's a pattern described in "Mapping a Class against Multiple Tables" in the "Advanced Data Mapping" chapter of the docs ;-) So, either this is a bug in the documentation because SA *can't* do this, or it's a bug in SA because it's supposed to do it. Your next comment: >this would suggest that providing an external API to build up the >same "synchronization" rules that joined inheritance uses could be >whats needed, something along the lines of: suggests that you're thinking the latter. Or have I misread you, and you're trying to solve the extra where clause problem but not the broken example? > mapper(Person, join(account, person), properties = { > 'id' : person.c.id, > 'handle': person.c.handle, > 'firstname': person.c.firstname, > 'lastname': person.c.lastname, > 'email_address': account.c.email_address, > 'password': account.c.password, > } > synchronize=[account.c.id==person.c.account_id] > ) > >I think I can also get the order of "account", "person" to be sorted >automatically.... Yeah, I thought you'd already got code that worked out the dependency order so I was surprised when I first saw that ;-) Tell you what, I'll write some unit tests and post them here. ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users