-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Computed relationship changes the shape of main query when selecting it as a computed column #2480
Comments
This was my take of the issue:
|
So since computed relationships are computed columns they can be used on I think we should keep the convention of
I would prefer that option. This would require considerable work though because we don't have computed columns in the schema cache. |
I think we should make sure to make the computed relationships features able to call all kinds of computed columns (i.e. scalar types with empty parens This would give us a way out of the "select affects the number of rows returned" mess we have right now. Summarizing this and the other issue: We currently have two problems:
We can fix both by making the new syntax cover all cases and then remove the old syntax. |
I see that taking a set-returning function as a computed column is acceptable, but the result is still unexpected (to me). Intuitively (and conventionally with PostgREST), a query with computed columns returns the same number of rows as the main query, as in a left join. That is, if we accept taking the
computed_films_m2o
as a computed column, it should returninstead. Otherwise, we have to break the current behevior of that a computed column never change the shape of the main query.
But the presented inner join is not a bug, but a postgresql feature, because PostgreSQL's behavior for a set-returning function in a query's select list is almost exactly the same as if the set-returning function had been written in a LATERAL FROM-clause item instead, i.e.,
is almost the same as
Regarding that, we could either exploit it as a postgrest feature that a set-returning function as computed column is for inner-join and a rowtype-returning scalar function as computed column is for left-join, or simply deny a set-returning function taken as a computed column for less headache.
Personally, I think the former option is very interesting and makes postgrest more flexible, although it requires explicit documentation and more tests and experiments.
Originally posted by @Iced-Sun in #2475 (comment)
The text was updated successfully, but these errors were encountered: