Closed joakim-emagine closed 3 years ago
Can you try using dasherized, it should translate to the underscored column name internally.
Hi, I am already using this setup in routes.php
Router::prefix('api', function ($routes) {
// $routes->extensions(['json', 'xml']);
$routes->resources('Countries', [
'inflect' => 'dasherize'
]
);
});
I meant calling the url with the dasherized column name. E.g.
fields[countries]=id,ctype,common-name
I meant calling the url with the dasherized column name. E.g.
fields[countries]=id,ctype,common-name
?fields[countries]=id,ctype,common-name,capital
ok, see result here:
{ "data": { "type": "countries", "id": "1", "attributes": { "ctype": "Independent State", "capital": "Kabul" }, "links": { "self": "/api/countries/1" } }, "query": { "default": [ { "query": "SELECT Countries.id AS `Countries__id`, Countries.ctype AS `Countries__ctype`, Countries.capital AS `Countries__capital` FROM countries Countries WHERE Countries.id = 1 LIMIT 1", "took": 1, "params": { "c0": 1 }, "numRows": 1, "error": null } ], "test": [], "debug_kit": [] } }
I just checked and there is no test case for Sparse Fieldsets using multi-word fields yet so you could be right. Would you like to assist in fixing this problem? A good place to start would be adding a failing test-case.
Okay, will see what I can do.
Any progress on this?
Closing as stale. Please reopen if this is still an issue.
For some reason the Api completely ignores columns with "_" in their names when specified with the fields[model]=column_name.
Without 'fields' option:
With ?fields[countries]=id,ctype,common_name,capital: