foreign_field is user_id, and suppose user_id is 2. When you add new record, $join->id is set to lastInsertID:
$this->id = $insert->connection->lastInsertID();
so it holds the value of contact.id, let's say it's 1 for our new record. If you execute delete after, the where() clause can cause deletion of incorrect record:
It appears that the use of $join->id in reveres join is incorrect.
Look at this file: https://github.com/atk4/data/blob/develop/src/Join_SQL.php#L211
With reverse join you are joining like this:
foreign_field
is user_id, and suppose user_id is 2. When you add new record, $join->id is set to lastInsertID:so it holds the value of contact.id, let's say it's 1 for our new record. If you execute delete after, the where() clause can cause deletion of incorrect record:
which would render to "where user_id = 1".