In my application I have a form that removes the relationship between
two data types without deleting each piece of data.

To do this I run a delete on the many to many relation lookup table
that stores the relationships.

For each of the relationships removed I run this line in web2py:

db(db.relation_table.data_type_A_id==data_type_A_id) &
db.relation_table.data_type_B_id==data_type_B_id)).delete()

This seems to work in that the relationships are destroyed, but
sometimes it doesn't delete the entire row in the relation_table, it
sometimes only sets the entry for data_type_A_ID to Null.

I want the entire row deleted.

When I experimented with removing 2 or 3 rows at a time, the second
and third row to be deleted would always be removed, but that first
row would always set data_type_A_id to Null.

I added some code to log all of my postgresql to see what was going on
there and it looks right:

DELETE FROM relation_table WHERE (table_A.data_type_A_id='X' AND
table_B.data_type_B_id='Y');

And when I copy and paste that directly into postgreSQL with existing
values populated, it works fine and removes the entire row including
the first one if I do multiples.

But web2py always sets the first row's data_type_A_id to Null

Any ideas?

~Lennon

Reply via email to