what version u use? i tried your thing, that is $ python -i zz.py s = create_session() j = s.query(Job)[0] #get first del j.files[0] s.flush() and seems to work
before: >>> for a in s.query(Job): print a.name, a.files ... Job 1 [<__main__.File object at 0xb78ec72c>, <__main__.File object at 0xb78e666c>] Job 2 [<__main__.File object at 0xb78ec72c>, <__main__.File object at 0xb78ec76c>] after: >>> for a in s.query(Job): print a.name, a.files ... Job 1 [<__main__.File object at 0xb78e666c>] Job 2 [<__main__.File object at 0xb78ec72c>, <__main__.File object at 0xb78ec76c>] --------- the only line removed was the "from .....orm import *" - u shouldnt use any of those internal stuff unless u know what u do. ciao svil On Wednesday 13 June 2007 13:13:58 David Bolen wrote: > from sqlalchemy import * > from sqlalchemy.orm import * > > meta = BoundMetaData('sqlite:///') > > jobs = Table('jobs', meta, > Column('id', Integer, primary_key=True), > Column('name', String)) > > files = Table('files', meta, > Column('id', Integer, primary_key=True), > Column('name', String)) > > jobs_files = Table('jobs_files', meta, > Column('job_id', Integer, > ForeignKey('jobs.id')), Column('file_id', Integer, > ForeignKey('files.id'))) > > > class Job(object): > pass > class File(object): > pass > > mapper(File, files) > mapper(Job, jobs, > properties = { 'files': relation(File, lazy=False, > backref=backref('jobs', > lazy=False), secondary=jobs_files) }) > > def setup(): > meta.create_all() > s = create_session() > > f1 = File() > f1.name = 'File 1' > f2 = File() > f2.name = 'File 2' > fc = File() > fc.name = 'File Common' > > j1 = Job() > j1.name = 'Job 1' > j2 = Job() > j2.name = 'Job 2' > > s.save(j1) > s.save(j2) > > j1.files.extend([f1, fc]) > j2.files.extend([f2, fc]) > > s.flush() --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---