I have just settled up a db connected service. I changed the Entity Identifier Name to match with my table, added three fields(one is the identifier) and put some length validation. No further changes, so far, so good, I can get/
, get/:id
with no problem.
The problem comes with the half post. doing a post does insert in the table but my response is 404 item not found. When trying to post the same data I get a duplicated key error, of course.
I don't understand what's wrong with the not found after inserting. Am I missing something?
UPDATE 3/9
Reading some post and groups I could narrow the problem to zf-apigility/src/DbConnectedResource.php
public function create($data) {
$data = $this->retrieveData($data);
$this->table->insert($data);
$id = $this->table->getLastInsertValue();
return $this->fetch($id);
}
Since my db is mysql and my primary key is a String i belive getLastInsertValue()
tries for an int id.
The solution i found was related to a postrgress db using features / sequence that apigility provided but i think there should be a simpler way to solve this. Apigility - Features.
I am looking for an aproach to either specify the method to get the last inserted value confirmation or to inherit from DbConnectedResource.php and re implement the create($data)
method.
I know this should be configured in the API/config/module.config.php
under service_manager
category but don't really know how.