Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid casting to table type when select= and media type handler are used #3224

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

wolfgangwalther
Copy link
Member

Previously using a generic mimetype handler failed when any kind of select= was given, because we tried to cast the select-result to the original table type. With this change, this cast is only applied when select=* is given implicitly or explicitly. This is the only case where this makes sense, because this guarantees that correct columns are selected in the correct order for this cast to succeed.

Resolves #3160

@wolfgangwalther
Copy link
Member Author

So I see this keeps working because the aggregate is defined for anyelement. What happens if the aggregate is defined for a particular table? In this case the response would have to be 406 Not Acceptable?

I added some tests for this case. They are still failing, but could you have a look at the test cases already? Would this cover it, WDYT? @steve-chavez

@wolfgangwalther wolfgangwalther force-pushed the custom-accept-handler branch 2 times, most recently from 457a805 to 4a472d2 Compare February 15, 2024 17:19
415 is for Content-Type and 406 for Accept headers.
…are used

Previously using a generic mimetype handler failed when any kind of select= was given, because
we tried to cast the select-result to the original table type. With this change, this cast is
only applied when select=* is given implicitly or explicitly. This is the only case where this
makes sense, because this guarantees that correct columns are selected in the correct order for
this cast to succeed.

Resolves PostgREST#3160
@wolfgangwalther wolfgangwalther merged commit 00fbe9f into PostgREST:main Feb 15, 2024
21 of 23 checks passed
@wolfgangwalther wolfgangwalther deleted the custom-accept-handler branch February 15, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Returning mimetypes via aggregates only works for select=*
2 participants