-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Support json_build_object
#179
Comments
json_build_object
in SQL queryjson_build_object
Currently, SafeQL mainly relies on PostgreSQL's PostgreSQL idiomatically infers the Due to that, SafeQL is unable to infer the exact result of I'll keep this open since I do plan eventually to support these kinds of limitations by moving away from RowDescription. |
Nice, that sounds pretty good for the future plan 🙌 Potentially also relevant: |
Awesome, thanks for the reply and thoughtful explanation :) |
@Newbie012 for the future design, one additional idea that I came across while writing my SQL tooling thread on Twitter/X was how @kristiandupont handles it in Kanel:
Source: kristiandupont/kanel#429 (comment) Sounds like it could be nice, to be able to specify the type information in the database 👍 |
Update - #190 (comment) |
fixed in 3.0.0 |
First off, I must say I genuinely enjoy using safeql. It's been a great asset to my projects, and I truly appreciate the hard work behind it. 🙌
While working with it recently, I stumbled upon a minor hiccup concerning type inference when using the
json_build_object
Postgres function. This function can be especially useful when using in tandem witharray_agg
.Scenario
Let's consider these tables for context:
With a goal to fetch user details along with their post details in a structured manner, I used the following query:
Describe the solution you'd like
{ user_id: number | null; name: string | null; post_details: any[] | null }
{ user_id: number | null; name: string | null; post_details: { post_id: number, title: string }[] | null }
Describe alternatives you've considered
A workaround for getting the correct types on arrays can be by using multiple arrays and combine the data based on the array index.
returns the following type:
Nevertheless, incorporating
json_build_object
directly would be a significant enhancement.Thank you for your time, and have a nice day!
The text was updated successfully, but these errors were encountered: