1

I am trying to write a simple SQL function that will be used as a computed field in Hasura.io platform.

CREATE OR REPLACE FUNCTION calling_mode(calling_row calling, hasura_session json)
RETURNS text AS $$
  SELECT CASE
    WHEN calling_row.seekerUserId = hasura_session ->> 'x-hasura-user-id' THEN 'seeker'
    WHEN calling_row.partnerUserId = hasura_session ->> 'x-hasura-user-id' THEN 'partner'
    ELSE 'none'
  END
$$ LANGUAGE sql STABLE;

This gives me an error missing FROM-clause entry for table "calling_row".

I tried looking through several docs, but it doesn't make any sense to me.

0

1 Answer 1

1

Probably that causes upper case letters, so if your original column name is seekerUserId, then into your function postgres converts it as seekeruserid, and that column is not found.

Try column names into double quotes, like:

CREATE OR REPLACE FUNCTION calling_mode(calling_row calling, hasura_session json)
RETURNS text AS $$
  SELECT CASE
    WHEN calling_row."seekerUserId" = hasura_session ->> 'x-hasura-user-id' THEN 'seeker'
    WHEN calling_row."partnerUserId" = hasura_session ->> 'x-hasura-user-id' THEN 'partner'
    ELSE 'none'
  END
$$ LANGUAGE sql STABLE;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.