-
-
Notifications
You must be signed in to change notification settings - Fork 158
fix: rpc return type #394
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: rpc return type #394
Conversation
RPC return types aren't getting propagated properly. E.g. if a function returns `boolean`, the `data` will be typed as `boolean[]`. To fix this, we change PostgrestBuilder's type parameter to be the actual type of `data`, instead of the element type of `data` (which assumes `data` is always an array, which is incorrect). In doing so we effectively remove all usage of `PostgrestResponse` and `PostgrestMaybeSingleResponse`. We can stop exporting these on the next major version. This also fixes the behavior of `.returns<NewResult>()`, which was inconsistent with the documentation (i.e. `data` was typed as `NewResult[]` instead of `NewResult`).
🎉 This PR is included in version 1.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
oof, i was wondering why all my types got borked overnight. |
Sorry about that @natedunn - do you mind sharing how it's breaking your types? While we consider it a bug here we do want to make sure the fix isn't causing more issues at least. |
@soedirgo Yeah I can understand the mentality there, so no worries. There's not much to describe in terms of my issues. The PR description laid it out pretty well, so I knew what I had to change: This stopped working
And this fixed the issue
|
I created this issue: #430 It is probably related to this. |
What kind of change does this PR introduce?
Fixes #387.
RPC return types aren't getting propagated properly. E.g. if a function returns
boolean
, thedata
will be typed asboolean[]
.To fix this, we change PostgrestBuilder's type parameter to be the actual type of
data
, instead of the element type ofdata
(which assumesdata
is always an array, which is incorrect).In doing so we effectively remove all usage of
PostgrestResponse
andPostgrestMaybeSingleResponse
. We can stop exporting these on the next major version.This also fixes the behavior of
.returns<NewResult>()
, which was inconsistent with the documentation (i.e.data
was typed asNewResult[]
instead ofNewResult
).