-
Notifications
You must be signed in to change notification settings - Fork 5
Support network_supeq and network_subeq by default #541
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
Conversation
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.
@plcplc I know this is quite hacky. If you have ideas on how to make this awesome, do let me know :)
SELECT DISTINCT ON (oprname) | ||
o.oprname AS operator_name, | ||
o.oprcode::text AS exposed_name, | ||
'custom' AS operator_kind, | ||
o.oprleft as operator_type, | ||
(SELECT typname FROM pg_catalog.pg_type WHERE oid = o.oprleft LIMIT 1) as operator_type_name | ||
FROM | ||
pg_operator as o | ||
WHERE | ||
o.oprname IS NOT NULL | ||
AND o.oprcode::text IS NOT NULL | ||
AND o.oprleft = o.oprright | ||
AND o.oprresult = (SELECT oid FROM pg_catalog.pg_type WHERE typname = 'bool' LIMIT 1) |
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.
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.
Considering that this gets the exposedName
from pg_operator.oprcode
, which is a reference to pg_proc.oid
(which when cast to text via ::text
yields the value pg_proc.proname
) I should think that simply adding network_supeq
to the list of known prefix-functions in the introspection options should make it appear (and text_pattern_ge
and friends too)
AND ( | ||
map.operator_type is null | ||
OR map.operator_type = op.argument1_type | ||
OR op.argument1_cast_chain LIKE ('% -> ' || map.operator_type_name) |
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.
so using the operator name and the type, i can know that >>=
on inet
should be called network_supeq
and should be an operator for the type cidr
which has a valid cast from cidr
to inet
.
6e46a0a
to
fb1b0c6
Compare
@plcplc changed the implementation to only add the functions to the list, as we discussed. |
"network_sub".to_string(), | ||
"network_subeq".to_string(), | ||
"network_sup".to_string(), | ||
"network_supeq".to_string(), | ||
"on_pb".to_string(), |
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.
👍
@@ -883,6 +883,31 @@ expression: default_configuration | |||
"foreignRelations": {}, | |||
"description": null | |||
}, | |||
"custom_test_cidr": { |
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.
It's a bit weird that we also update v3 and v4 test snapshots for this change, but I suppose it follows from each version using sharing the same test database definition.
What
This PR lists network_supeq and network_subeq in the default allowed prefix functions, to complete support for types such as CIDR.
How
Add them to the default list, add tests, and regenerate configs.