While creating an example for #987 i ended up in this error.
create table one(id text, primary key(id));
create table two(id text, primary key(id), two text references one(id));
grant select, references on one to testuser;
grant select, references on two to testuser;
```
curl -X GET "http://localhost:3000/one?select=two(*)" -H "accept: application/json" ; echo
```json
{"hint":"No function matches the given name and argument types. You might need to add explicit type casts.","details":null,"code":"42883","message":"function row_to_json(text) does not exist"}
you have to select at least one field (primary key preferably) from table one (that's your first problem.) and don't use *, specify the primary key form table two and any additional fields you need
if that does not solve your problem, check what version of PostgreSQL you are using, has to be 9.3+ (although i see no reason for not using 9.6)
This also seems to appear for me when I selected a column from a referring table which has the same name as it's table. I.e.
CREATE TABLE parent {
parent_id serial PRIMARY KEY
}
CREATE TABLE child {
child_id serial PRIMARY KEY,
parent_id integer REFERENCES parent(parent_id) NOT NULL,
child text NOT NULL
}
It seems that in this case, http://localhost:8000/parent?parent_id=eq.1&select=child(child_id, child)
would result in row_to_json(text) does not exist, with the solution being to rename the child column in the child table to something other than the name of the table, i.e. full_name text and thus calling http://localhost:8000/parent?parent_id=eq.1&select=child(child_id, full_name).
disclaimer: haven't tried to run this exact example, but ran into this situation w/ a similar fix as detailed above.
@ruslantalpa should this bug than be reopened?
Can reproduce the errors in both examples in v0.4.3.0 but not on master.
The fix was done in https://github.com/begriffs/postgrest/pull/996, tests were added here https://github.com/begriffs/postgrest/commit/e1cab584a3671171dc1b93cf9e94f0a51b9d381a.
Most helpful comment
Can reproduce the errors in both examples in v0.4.3.0 but not on master.
The fix was done in https://github.com/begriffs/postgrest/pull/996, tests were added here https://github.com/begriffs/postgrest/commit/e1cab584a3671171dc1b93cf9e94f0a51b9d381a.