You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When table has no Idenity field (autoincrement), the
PhalconRest\Api\Resource returns false $_modelPrimaryKey for all CRUD methods (or other using Resource class).
It can be problem with generated primary keys (like uuid or so).
{ "error": { "code": 0, "message": "Syntax error, unexpected token EQUALS, near to ' :id: LIMIT :APL0:', when parsing: SELECT [App\\Model\\Customer].* FROM [App\\Model\\Customer] WHERE [App\\Model\\Customer]. = :id: LIMIT :APL0: (103)", "developer": { "file": "/api/vendor/redound/phalcon-rest/src/PhalconRest/Mvc/Controllers/CrudResourceController.php", "line": 138, "request": "GET /customer/1464437091" } } }
I suppose, the best way to solve it, is to parse (when getting identity as false) $modelsMetaData->getPrimaryKeyAttributes() array, and (also) deal with multi-pk tables.
The text was updated successfully, but these errors were encountered:
you need to use metadata like this.
`public function metaData()
{
return array(
// Every column in the mapped table
MetaData::MODELS_ATTRIBUTES => [
"ArticuloCodigo",
"ArticuloDigito",
"ArticuloDescripcion",
"ArticuloUnidadCaja",
"ArticuloUnidadDisplay",
],
// Every column part of the primary key
MetaData::MODELS_PRIMARY_KEY => [
"articulo_codigo",
],
// Every column that isn't part of the primary key
MetaData::MODELS_NON_PRIMARY_KEY => [
"ArticuloDigito",
"ArticuloDescripcion",
"ArticuloUnidadCaja",
"ArticuloUnidadDisplay",
],
// Every column that doesn't allows null values
MetaData::MODELS_NOT_NULL => [
],
// Every column and their data types
MetaData::MODELS_DATA_TYPES => [
"ArticuloCodigo" => Column::TYPE_INTEGER,
"ArticuloDigito" => Column::TYPE_VARCHAR,
"ArticuloDescripcion" => Column::TYPE_VARCHAR,
"ArticuloUnidadCaja" => Column::TYPE_INTEGER,
"ArticuloUnidadDisplay" => Column::TYPE_INTEGER,
],
// The columns that have numeric data types
MetaData::MODELS_DATA_TYPES_NUMERIC => [
"ArticuloCodigo" => true,
"ArticuloUnidadCaja" => true,
"ArticuloUnidadDisplay" => true,
],
// The identity column, use boolean false if the model doesn't have
// an identity column
MetaData::MODELS_IDENTITY_COLUMN => "articulo_codigo",
);`
When table has no Idenity field (autoincrement), the
PhalconRest\Api\Resource returns
false
$_modelPrimaryKey for all CRUD methods (or other using Resource class).It can be problem with generated primary keys (like uuid or so).
{ "error": { "code": 0, "message": "Syntax error, unexpected token EQUALS, near to ' :id: LIMIT :APL0:', when parsing: SELECT [App\\Model\\Customer].* FROM [App\\Model\\Customer] WHERE [App\\Model\\Customer]. = :id: LIMIT :APL0: (103)", "developer": { "file": "/api/vendor/redound/phalcon-rest/src/PhalconRest/Mvc/Controllers/CrudResourceController.php", "line": 138, "request": "GET /customer/1464437091" } } }
https://github.com/redound/phalcon-rest/blob/master/src/PhalconRest/Api/Resource.php#L118
I suppose, the best way to solve it, is to parse (when getting identity as false) $modelsMetaData->getPrimaryKeyAttributes() array, and (also) deal with multi-pk tables.
The text was updated successfully, but these errors were encountered: