-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
feat: select-query-parser-v2 #558
Conversation
feat: Release V1
fix v1 spec
…sion Chore/revert to old typedoc version
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Commits](isaacs/minimatch@v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
This makes the doc comments show up for all the function signatures, instead of just the first one.
Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](json5/json5@v2.2.1...v2.2.3) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
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`).
fix: rpc return type
* Prettify intersected types when selecting multiple columns Resolves #398 * update type test --------- Co-authored-by: Bobbie Soedirgo <[email protected]>
Alright ! I've been able to use this new version within the larger codebase without lint errors in Only change I had to make on the
So this is now ready for review whenever you have time for it @soedirgo 👍 |
Would this PR fix type error when using virtual columns (ie. calling postgres function as column)? |
Hey, I'm not sure what issue you're referring too I don't think so, from my understanding the only way to call functions in postgrest is via RPC (https://docs.postgrest.org/en/v12/references/api/functions.html). The only way I think you could achieve to use them as columns would be via some kind of views maybe ? Also note that this PR does not impact any runtime behavior, only make the result types inference match it better. |
What I was referring to does work (see: https://docs.postgrest.org/en/latest/references/api/computed_fields.html#computed-fields), my question is about fixing the generated type as the typescript error message is preventing builds of my next.js app to succeed. I've been forced to add ts-ignore everywhere since 2 years and I was thinking that this PR sounds like it would fix this issue |
Thank's for pointing out the case, I'll have a look, if it's correctly picked up as a column during introspection then it should work. Otherwise, if it's considered a function I don't think the current version will fix this issue. I'll make a test case to make sure of it tough. |
I see in any case thank you for taking the time to improve this part of supabase SDK! |
I'm locking the discussion to keep the focus on the PR review. Please open an issue or comment over a current one if you want to discuss details. |
This reverts commit ac6165c.
* move all parsing logic into one file to clearly delineate module boundaries (parsing vs. result type resolution) * collapse non-embedded resource parsing into one type * make `!left` a no-op * resolve all errors in parser.test-d.ts
d52234f
to
c6c2795
Compare
What kind of change does this PR introduce?
What is the current behavior?
There are several result type mismatches referenced across multiple issues:
I have reproduced these issues in test cases with similar topologies to verify runtime behavior and ensure proper type inference.
What is the new behavior?
The rewrite should resolve all the related issues regarding select operations that I’ve encountered so far. However, I may have missed some cases, and there could be regressions in edge cases (despite passing all existing tests). Given the number of related issues, I’m unsure if the previous test coverage was sufficient. I recommend to deploy that out over an
rc
version first in coordination withsupabase-js rc
candidate so we can gather feedbacks about possibles regression before making the switch.Additionally, we might need to evaluate how this performs on large databases with many tables and relations. The use of recursive types could potentially introduce performance concerns in such cases.
Additional context
I didn’t rewrite the original parser for fun. After spending a considerable amount of time trying to fix the existing one (I swear I tried see: #554 😓 ), it became clear that starting fresh with a cleaner, more testable, and debuggable version was necessary. I know it make for a big PR but I wasn't able to really reduce more than that the amount of changes, sorry 😅