delete row issue with postgre many to many relation table and Web2py

83 views
Skip to first unread message

Lennon

unread,
Jul 1, 2010, 4:34:03 PM7/1/10
to web2py-users
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

mdipierro

unread,
Jul 1, 2010, 5:22:47 PM7/1/10
to web2py-users


On 1 Lug, 15:34, Lennon <lpru...@hotmail.com> wrote:
> 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 is odd because web2py just transpates this in the SQL below and
sends it to the server.
Something else is causing the problem.
Reply all
Reply to author
Forward
0 new messages