-
-
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
type cast with horizontal filtering #1952
Comments
@fjf2002 You can do this with a computed column, check this previous answer here: #1651 (comment)
Hm, this feature request has come up before but the main drawback of implementing casting at the filter level is that it invalidates indexes. computed columns are safer in that regard. |
@steve-chavez Thank You for the hint with computed columns. That works.
Are you sure that a WHERE clause like WHERE mycolumn = myconstant::mytype does NOT USE the index on mycolumn? I would doubt that, because the type cast happens on the constant value, not on the column. A test of both sql statements explain select * from foo where bar = 25603;
explain select * from foo where bar = 'person'::regclass; ... showed me both times the same query plan, using the index on table_oid. |
Please see this #1651 (comment) for the background on this. The problem is not expected when the right cast is used, but when the wrong cast is used. This could increase the surface for DDoS attacks. |
As of right now, the same reasoning as in #1651 (comment) holds true. Unless we find better arguments to support a syntax like this, we're unlikely to continue with this, so I'll close this for now. |
ok, thanks! |
Environment
Description of issue
On page https://postgrest.org/en/v8.0/api.html?highlight=filtering#vertical-filtering-columns I learnt that type casting the columns is possible.
I would like to type cast on horizontal filtering, i. e. I need something at the REST level that translates at the SQL level to:
Let's put it like this: Probably horizontal filtering on any user defined type needs a string-to-user-defined-type-cast like this? Are user defined types currently locked out from horizontal filtering?
More precisely, foo.bar has type regclass, and I am failing with both
(at REST level)
The text was updated successfully, but these errors were encountered: