dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 377 forks source link

cascade remove #546

Closed sm3azr closed 10 years ago

sm3azr commented 10 years ago

When I call remove for a model that has a hasMany association, it fails because a foreign key reference is still there (ER_ROW_ISREFERENCED: Cannot delete or update a parent row: a foreign key constraint fails). Debugging the query shows me that the cascade remove is being applied because the row that has the foreign key is being deleted first. The problem seems to be that orm is trying to delete the model before the associations are removed completely removed. Can someone confirm this? I am using mysql.

sm3azr commented 10 years ago

I think I solved the problem. What was causing this was the fact that I was using a connection pool. If I don't use a connection pool, the cascade remove is applied with success.