-
-
Notifications
You must be signed in to change notification settings - Fork 162
feat: postgrest 13 add maxaffected in client libraries #619
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
base: avallete/psql-436-feedback-request-postgrest-js-and-postgrest-v13-integration
Are you sure you want to change the base?
Conversation
…tgrest-v13-integration' into avallete/psql-372-postgrest-add-maxaffected-in-client-libraries
…tgrest-v13-integration' into avallete/psql-372-postgrest-add-maxaffected-in-client-libraries
src/PostgrestTransformBuilder.ts
Outdated
/** | ||
* Set the maximum number of rows that can be affected by the query. | ||
* Only available in PostgREST v13+ and only works with PATCH and DELETE methods. | ||
* | ||
* @param value - The maximum number of rows that can be affected | ||
*/ | ||
maxAffected( | ||
value: number | ||
): ClientOptions['postgrestVersion'] extends 13 | ||
? Method extends 'PATCH' | 'DELETE' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice-to-have on typescript would be a validation that the function returns SETOF
, otherwise the failure would be at runtime I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch didn't tested the rpc
they do have their own kind of typing though because they're a bit specifics.
About the "set of" that's actually something I wanna work on. It will be related to "embedded relationships with functions". I have some draft I need to find the time to work on it.
For now I think runtime error is okay, but we'll surely be able to catch that at type level at some point indeed. Just wondering, what if the function doesn't returns a setof but just plain records ? Or return table
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I think runtime error is okay, but we'll surely be able to catch that at type level at some point indeed. Just wondering, what if the function doesn't returns a setof but just plain records ? Or return table ?
Right now it will just fail silently, but we're working on a fix to raise an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a specific case for RPC
calls as we can't really know the request method at type inference time, nor can we know if it returns a `setof` another table. So it'll be a bit of degraded experience typewise (more chances to have error only at runtime) but should be good enough for now.
…tgrest-v13-integration' into avallete/psql-372-postgrest-add-maxaffected-in-client-libraries
1904574
to
9ef7ee0
Compare
What kind of change does this PR introduce?
Headers
APIHeaders
)