Wrong user_id after saving why?

Hello, i wrote a function to add a friend to a user but if i save the $data it will use a user_id that differs from what i provided.

debug($data) shows:

APP/Controller/UsersController.php (line 243 )
[‘friends’ => [(int) 0 => [‘friendslist_id’ => (int) 7,‘user_id’ => (int) 1,‘approved’ => (int) 33333,],],

but the database entry shows: user_id’ => (int) 7

Function is:

$user = $this->Users->get($id, [
‘contain’ => [ ‘Friendslists.Friends’],
]);

$data = [
‘friends’ => [
[
‘friendslist_id’ =>$user->friendslist->id,
‘user_id’ => $this->request->getAttribute(‘identity’)->getIdentifier(),
‘approved’ => 33333,
],],

];

//debug($data);exit;
$user->setDirty(‘friends’, true);
$user = $this->Users->patchEntity($user, $data);
$this->Users->save($user);

Maybe you have a error in your asociation?

What does debug($user->friends) give you after the patchEntity call?