I'm having trouble doing a remove() through a Reference. After doing the remove, the deleted row reappears in the Reference, even when I refetch the object containing the Reference. The test program is below. I would expect it to print None twice, showing that both References are empty.
Is this a bug? Maybe I don't understand something about References. Or is the cache holding the deleted row by mistake? I've tried this on 0.14 and 0.15, with both sqlite and postgresql. The test program resembles the one this bug, but I'm not sure it's related: https://bugs.launchpad.net/storm/+bug/241530 . Thanks, Dan -----------------------------------------------------------------+ from storm.locals import * class T1(Storm): __storm_table__ = 't1' id = Int(primary=True) t2 = Reference(id, 'T2.t1_id') def __init__(self, id): self.id = id class T2(Storm): __storm_table__ = 't2' t1_id = Int(primary=True) # foreign key referencing T1 def __init__(self, t1_id): self.t1_id = t1_id db = create_database('sqlite:') store = Store(db) store.execute('create temporary table t1 (id INTEGER PRIMARY KEY)') store.execute('create temporary table t2 (t1_id INTEGER PRIMARY KEY)') # Store two rows in T1 and two corresponding rows in T2 t1a = T1(33); store.add(t1a) t1b = T1(66); store.add(t1b) t2a = T2(33); store.add(t2a) t2b = T2(66); store.add(t2b) store.commit() # Now remove both T2 rows, but in two different ways. store.remove(t2a) # removing t2a directly store.remove(t1b.t2) # remove t2b indirectly, via the Reference store.commit() # Confirm there are no T2 rows now. print "# of T2 rows:", store.find(T2).count() # Get the T1 objects again. t1a_new = store.find(T1, T1.id == 33).one() t1b_new = store.find(T1, T1.id == 66).one() # Shouldn't these both print None, because both T2 rows have been deleted? print "t1a_new.t2:", t1a_new.t2 print "t1b_new.t2:", t1b_new.t2 -- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
