This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
Vertical filtering on inserts #130
Comments
Would be in the querystring as usual, if I'm understanding you correctly, there's an example here https://github.com/begriffs/postgrest/blob/master/test/Feature/InsertSpec.hs#L41-L50. it "filters columns in result using &select" $
request methodPost "/menagerie?select=integer,varchar" [("Prefer", "return=representation")]
[json| [{
"integer": 14, "double": 3.14159, "varchar": "testing!"
, "boolean": false, "date": "1900-01-01", "money": "$3.99"
, "enum": "foo"
}] |] `shouldRespondWith` [str|[{"integer":14,"varchar":"testing!"}]|]
{ matchStatus = 201
, matchHeaders = [matchContentTypeJson]
} |
Thanks for the pointer. I think I got the syntax right, but it seems that the primary key needs to be among the values in the For example, after the setup in Tutorial 0, I can do: > curl "http://localhost:3000/todos?select=id" -X POST -H "Content-Type: application/json" -H "Prefer: return=representation" -d '{"task": "do bad thing"}'
[{"id":8}]%
> curl "http://localhost:3000/todos?select=id,task" -X POST -H "Content-Type: application/json" -H "Prefer: return=representation" -d '{"task": "do bad thing"}'
[{"id":9,"task":"do bad thing"}]% But I cannot do: > curl "http://localhost:3000/todos?select=task" -X POST -H "Content-Type: application/json" -H "Prefer: return=representation" -d '{"task": "do bad thing"}'
{"details":"Row number 0","message":"Row error: unexpected null"}% |
Yeah, that's a bug reported in PostgREST/postgrest#1087, this will be fixed on the next release. |
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
For insertions, the docs talk about using
Prefer: return=representation
to get the inserted object back. Moreover they also talk about applying vertical filtering to it, e.g.,?select=foo
.Where would one specify the
select=foo
part in thePOST
request of an insert operation?The text was updated successfully, but these errors were encountered: