Cannot join table after .rpc() call

I have a function like this:
create or replace function search_items(lang regconfig, query text)
  returns table (id uuid, title text, location point, price numeric(16,2), currency_id bigint, thumbnail text)
  language plpgsql
  as
  $$
declare
  query_vector tsquery = to_tsquery(lang, query);
begin
  return query
    select 
      a.id,
      a.title, 
      a.location,
      a.price,
      a.currency_id,
      a.thumbnail
    from item a,
    lateral create_fts_vector(a.title, a.description, lang) weighted_fs_vector
    where weighted_fs_vector @@ query_vector
    order by ts_rank(weighted_fs_vector, query_vector) 
    desc;
end;
$$;


I'm trying call my function and join it with currency table which has id and value:
    return _client 
        .rpc('search_items', 
              params: {'lang': 'italian', 'query': queryText})
        .select(
            'id, title, location, price, currency(id, value), thumbnail')
        .execute()

I'm getting error: Could not find a relationship between 'pgrst_source' and 'currency' in the schema cache.

What am I doing wrong? How can I join table based on id I get in rpc call? Currency table has primary key id.
Was this page helpful?