https://supabase.com/ logo
#help
Title
# help
m

max

04/26/2022, 8:38 AM
I'm trying to use the following postgres function:
Copy code
create or replace function get_activities(radius int, point text) 
returns setof activities as $$

    var json_result = plv8.execute(
    "SELECT activities.id, activities.name, activities.time, activities.participant_limit, row_to_json(activities_user.*) AS user FROM activities LEFT JOIN LATERAL ( SELECT users.full_name, users.avatar_url FROM users WHERE activities.added_by = users.id ) AS activities_user ON TRUE WHERE ST_DWithin(location, $1::geometry, $2) ORDER BY time asc", [point, radius]
    );

    return json_result;
$$ language plv8;
Running the query itself works fine, but when trying to run this function via
supabase.rpc
I get a 500 with error code XX000 and message "field name / property name mismatch". I'm guessing that it is because my return type "activities" does not include the users table's field that I'm adding as part of the query. Any ideas how I can fix this?
n

Needle

04/26/2022, 8:38 AM
Hello @max! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
s

Steve

05/01/2022, 6:35 AM
Did you solve your issue?
n

Needle

05/01/2022, 6:35 AM
max (2022-04-26)
s

Steve

05/01/2022, 6:36 AM
Full error of the RPC would be helpful to debug further
(message,details,hint,code)