我有一个logschema.movement
返回 table 子集的PostgreSQL 函数logschema.movement
,该函数如下所示:
CREATE OR REPLACE FUNCTION logschema.movement(
"ids" bigint[], "date" TEXT)
RETURNS SETOF logschema.movement
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $$
BEGIN
RETURN QUERY (SELECT * FROM logschema.movement WHERE "ids" = ANY ("ids") AND "day" >= $2::TIMESTAMP);
END;
$$;
这个函数在 PostgreSQL 中工作,例如SELECT logschema.movement(ARRAY[1,2,3], '2021-09-09')
不返回错误。如果我尝试使用 PostgREST 和 axios 查询函数,如下所示:
let payload = {ids: [1,2,3], date: "2021-09-08"}
return await RequestService.postData(new URL(this.api + `/rpc/movement`, this.urlBase), payload);
我收到一条很长的错误消息,其中包含:
...
data:
{ hint:
'No function matches the given name and argument types. You might need to add explicit type casts.',
details: null,
code: '42883',
message:
'function logschema.movement(lastBatteryChangeDate => text, pseudoIds => text) does not exist' } }
...
在我看来,我的数组已转换为字符串,但我不确定。
我的 PostgreSQL 版本是PostgreSQL 12.8 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit
,我的 PostgREST 版本是v7.0.1