Michael On 9/10/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > hey Roger - > > can you reopen ticket #570 and attach your patch there ? FTR, the > 0.4 codebase does this differently and is probably "correct" over > there (but also, not tested since I dont have FB).
I guess you meant #370.. :) Well, it is still opened... I tried to upload the patches, but found no option to do this operation on an existing ticket (only for new tickets)... I logged as guest/guest, since there's also no option to register myself as a new user. So, here are the 2 patches and a test script... (hope the list accept attachments). Cheers, Roger --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---
from sqlalchemy import * from sqlalchemy.orm import * dburi = "firebird://SYSDBA:[EMAIL PROTECTED]//tmp/test.fdb" engine = create_engine(dburi) metadata = MetaData() conn = engine.connect() users_table = Table('T_USER', metadata, Column('id', Integer, primary_key=True), Column('name', String(20))) prefs_table = Table('T_PREFS', metadata, Column('id', Integer, primary_key=True), Column('user_id', Integer, ForeignKey('T_USER.id')), Column('name', String(20))) class User(object): pass class UserPref(object): pass mapper(User, users_table, properties = dict( preferences = relation(UserPref, cascade="all, delete-orphan"), )) mapper(UserPref, prefs_table) metadata.bind = engine session = create_session(bind=engine) users_table.create(checkfirst=True) prefs_table.create(checkfirst=True) # delete existing data prefs_table.delete().execute() users_table.delete().execute() # populate initial data users_table.insert().execute(dict(id=1, name='Smith'), dict(id=2, name='Mark')) prefs_table.insert().execute( dict(id=1, user_id=1, name='Smith-1'), dict(id=2, user_id=1, name='Smith-2'), dict(id=3, user_id=1, name='Smith-3'), dict(id=4, user_id=2, name='Mark-1'), dict(id=5, user_id=2, name='Mark-2') ) assert select([func.count(users_table.c.id)]).scalar() == 2 assert select([func.count(prefs_table.c.id)]).scalar() == 5 u = session.query(User).get(1) session.delete(u) session.flush() assert select([func.count(users_table.c.id)]).scalar() == 1 assert select([func.count(prefs_table.c.id)]).scalar() == 2 u = session.query(User).get(2) u.preferences = [] session.flush() assert select([func.count(users_table.c.id)]).scalar() == 1 assert select([func.count(prefs_table.c.id)]).scalar() == 0
370_branch_0.3.patch
Description: Binary data
370_branch_0.4.patch
Description: Binary data