FriendsOfCake / crud-json-api

Build advanced JSON API Servers with almost no code.
https://crud-json-api.readthedocs.io/
MIT License
56 stars 32 forks source link

Problem with Has Many associations primary key #138

Closed igorfelluga closed 4 years ago

igorfelluga commented 4 years ago

Hi I got this problem when I save a record with has many associations, my table not use standard primary key "id" because I found it like this :(. I found the problem in src/Listener/JsonApiListener.php, line 219 and 222 $query = $hasManyTable->find() ->select(['id']) ->where([ $entityForeignKey => $primaryResourceId, 'id IN' => $hasManyIds, ]); I fixed like this $query = $hasManyTable->find() ->select([$hasManyTable->getPrimaryKey()]) ->where([ $entityForeignKey => $primaryResourceId, $hasManyTable->getPrimaryKey().' IN' => $hasManyIds, ]);

dakota commented 4 years ago

Hi, would you be able to submit a pull request?

igorfelluga commented 4 years ago

No sorry

dakota commented 4 years ago

Fixed