Optionally prefix computed column procedures with the table name #2507
-
Environment
Description of issueQuite often, I use Postgrest in combination with Graphile, because most of my customers need both, a REST API and a Graphql API. Unfortunately, Postgrest and Graphile are following different naming conventions for computed columns or computed relationships (please see here for Postgrest and Graphile). CREATE TABLE people (
fname text,
lname text
);
-- Postgrest convention, without any prefix.
CREATE FUNCTION full_name(people) RETURNS text AS $$
SELECT $1.fname || ' ' || $1.lname;
$$ LANGUAGE SQL;
-- Graphile convention, prefixed by the table name.
CREATE FUNCTION people_full_name(people) RETURNS text AS $$
SELECT $1.fname || ' ' || $1.lname;
$$ LANGUAGE SQL; Except from the prefix, almost all functions could be compatible. (There are other differing conventions, but it's quite easy to satisfy them at the same time in most cases.) That's why I would love to see support for an optional table-name-prefix for computed column procedures in Postgrest. (This prefix should be skipped from the API.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hm. That prefix would be quite contrary to our naming conventions. Maybe you can solve it like this:
CREATE FUNCTION <table_name>_<func_name>(<table_name>) RETURNS <return_type> AS $$
SELECT <func_name>($1);
$$; This way you only need to maintain one set of functions, but have both? |
Beta Was this translation helpful? Give feedback.
Hm. That prefix would be quite contrary to our naming conventions.
Maybe you can solve it like this:
full_name(...)
function onlyThis way you only need to maintain one set of functions, but have both?