yii2-relation-trait icon indicating copy to clipboard operation
yii2-relation-trait copied to clipboard

Added onCondition and where condition for the FK delete queries

Open deadmantfa opened this issue 7 years ago • 2 comments

#54 Fixes Fixed random deletion of data due to not honouring the onCondition and where condition

deadmantfa avatar Feb 08 '18 06:02 deadmantfa

@deadmantfa Seems like this fix works in the manner that it prevents related records from being deleted, but now deleting related records doesn't work at all.

Seems like issue is caused by commenting out code in https://github.com/mootensai/yii2-relation-trait/pull/55/commits/98ab3c8b6b0a230b15375d481a098851d36b280e

Edit: Sorry, my bad, doens't work just when you delete all related records, and is not caused by commenting code in previously mentioned commit.

sime15 avatar Feb 15 '18 11:02 sime15

@sime15 Yes I agree, but that code deleted everything which was not sent it. For example if there are 5 relations and only the parent and 2 relation data was updated the next 3 would be deleted which was not by design when I as using it i.e. ver 1.1.6 I worked on that code and fixed the issue first and created a mess for myself where we lost a lot of data. Thank god for backups ;P so I commented out that code as i did not need it. But It was not there in the original PR request. This is my first time contributing with a PR. So any guidance would be great.

deadmantfa avatar Feb 16 '18 14:02 deadmantfa