1

So basiclly i want to create a computed field which is very basic, Get the full name from the database.

CREATE FUNCTION author_full_name(user_row users)
RETURNS TEXT AS $$
  SELECT user_row.firstName || ' ' || user_row.lastName
$$ LANGUAGE sql STABLE;

Here is the users table: users id int, firstName text, lastName text

db ss: https://ibb.co/gm1xzK2

I always end up with this error : "SQL Execution Failed no schema has been selected to create in. null"

Lord Zeus
  • 35
  • 1
  • 5
  • 1
    Did you set Function Schema for function as it shown here: https://hasura.io/docs/latest/_images/computed-field-create1.png ? – Alex Yu Aug 27 '21 at 05:02
  • The function_name doesn't appear because the SQL is not working because of the error – Lord Zeus Aug 27 '21 at 12:35
  • 1
    So if you add `public` to `CREATE FUNCTION public.author_full_name` as @Jesse Carter suggested - it works? – Alex Yu Aug 29 '21 at 11:27

1 Answers1

1

You need to either fully qualify the schema where the function should be created eg public.author_full_name or update the search path in Postgres so that it defaults to a schema (public or otherwise)

See the answer here https://stackoverflow.com/a/41207765/1364771

Jesse Carter
  • 20,062
  • 7
  • 64
  • 101