GraphQL:添加计算字段时出错
GraphQL : Error while adding computed fields
我正在尝试使用 hasura API 向模式“abc”中的 graphql table“用户”添加一个计算字段 API 但收到以下错误:
Saving computed field failed
in table "abc.user": in computed field "full_name": the computed field "full_name"
cannot be added to table "abc.user" because the function "abc.fullname" is
of type VOLATILE; cannot be added as a computed field
函数添加正确:
CREATE OR REPLACE FUNCTION abc.fullname(userrow abc.user)
RETURNS TEXT AS $$
BEGIN
SELECT userrow.first_name || ' ' || userrow.last_name;
END;
$$ LANGUAGE plpgsql;
我可以 select 从下拉列表中使用函数“全名”,但在添加计算字段时出错。任何指导表示赞赏。谢谢。
错误消息试图告诉您。您需要将该函数显式声明为 immutable
,以便它可以在计算列的定义中使用:
create or replace function abc.fullname(userrow abc.user)
returns text immutable as $$
begin
select userrow.first_name || ' ' || userrow.last_name;
end;
$$ language plpgsql;
我正在尝试使用 hasura API 向模式“abc”中的 graphql table“用户”添加一个计算字段 API 但收到以下错误:
Saving computed field failed
in table "abc.user": in computed field "full_name": the computed field "full_name"
cannot be added to table "abc.user" because the function "abc.fullname" is
of type VOLATILE; cannot be added as a computed field
函数添加正确:
CREATE OR REPLACE FUNCTION abc.fullname(userrow abc.user)
RETURNS TEXT AS $$
BEGIN
SELECT userrow.first_name || ' ' || userrow.last_name;
END;
$$ LANGUAGE plpgsql;
我可以 select 从下拉列表中使用函数“全名”,但在添加计算字段时出错。任何指导表示赞赏。谢谢。
错误消息试图告诉您。您需要将该函数显式声明为 immutable
,以便它可以在计算列的定义中使用:
create or replace function abc.fullname(userrow abc.user)
returns text immutable as $$
begin
select userrow.first_name || ' ' || userrow.last_name;
end;
$$ language plpgsql;