-
Notifications
You must be signed in to change notification settings - Fork 649
Add a typescript query builder for views #3812
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joshua-spacetime
approved these changes
Dec 4, 2025
Collaborator
joshua-spacetime
left a comment
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.
I mainly reviewed the api. Improving compile-time safety will be addressed in follow up patches.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
This adds a way to build queries with typescript views, and it allows views to return queries (if the return type of the query is an array).
For examples and syntax, you can look at the tests in crates/bindings-typescript/tests/query.test.ts.
To play around with the syntax, you might find it easier to look in crates/bindings-typescript/src/server/view.test-d.ts.
This could still use some cleanup, and there are some places where the type safety is imperfect. I'll try to list the known limitations here:
eqfor columns that are product types, even though the query engine doesn't support it. This can be fixed later, and it would only be a breaking change for modules that have invalid queries.u16andu32).API and ABI breaking changes
This adds some new API surface, but does not break existing code.
Expected complexity level and risk
Testing
For automated tests, there are unit tests to see what sql gets emitted in
tests/query.test.ts, and some tests of the types inview.test-d.ts.I've also run some manual tests with a typescript module with views.