https://supabase.com/ logo
Hey! I have a situation where my function behaves ...
# help
e
Hey! I have a situation where my function behaves differently from Insomnia (HTTP Client) and when I use .rpc() from Supabase Client. Insomnia response is excactly as expected, where it returns one row that fits the filters passed in consistently. Supabase client responds with rows that does not fit the filters.
n
Hello @Evjen! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! 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
Can you post what the function looks like? what the function call looks like from both Insomnia and the rpc call? Screenshot of the results.
e
My function: SELECT * FROM random_activity where ST_DWithin(ST_MakePoint(random_activity.lat, random_activity.lng)::geography, ST_MakePoint(lat, lng)::geography, distance, true) AND "estimatedHigherPrice" <= maxPrice; I've included screenshots of my ActivityFilter struct in Swift which is encoded to JSON, and each field matches the parameter names of the function and the query. Also my Insomnia call which works fine, and the API Docs. This might be an issue with the Supabase Client for Swift, but It's almost working, so not sure where the mistake is. Wish I could find a way in the API Logs to see the json body of the request.
s
I haven't seen the results from the rpc. Also, was your function created as a SECURITY DEFINER or a SECURITY INVOKER?
e
Yeah sorry, the response from the rpc is successful in that it returns a row correctly. The issue is that it can return any of the three rows I have in my table, but should only be able to return one of them based on the filters passed. Not sure about what you meant with Definer or Invoker, this is a Database function which is in Alpha Preview: supabase.com/project/{projectId}/database/functions
s
The rpc calls are just making restful calls like you have in your Insomnia, not sure how you can view these in the Swift development environment.
e
I finally figured it out. It wasn't a difference from Insomnia and rpc 😅 The issue was that I had arguments for my function that was named the same as fields in my table (lat & lng), so they effectivly did not work. Had to change my function params to geoLat and geoLong so it did not confuse the two.