I'm trying to use the following postgres function:...
# help
m
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
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
Did you solve your issue?
n
max (2022-04-26)
s
Full error of the RPC would be helpful to debug further
(message,details,hint,code)