supabase-py icon indicating copy to clipboard operation
supabase-py copied to clipboard

sanitize_param() not correctly resolving when using nested columns

Open vidski opened this issue 2 years ago • 6 comments

Describe the bug When filtering for a nested column, sanitize_param is adding unneccessary " "

To Reproduce supabase.table('character_inventory').select('character(*), slot, item(*, template(*))').eq('character.user_id', user_id).execute()

resolves to: /rest/v1/character_inventory?select=character(*),+slot,+item(*,+template(*))&"character.user_id"=eq.2731f9cc-17f4-42a2-839a-d25dfe8d90a8 returns HTTP 400

Expected behavior Should resolve to: /rest/v1/character_inventory?select=character(*),+slot,+item(*,+template(*))&character.user_id=eq.2731f9cc-17f4-42a2-839a-d25dfe8d90a8 returns HTTP 200

Screenshots image image

Desktop:

  • OS: Windows 11
  • Version: latest

vidski avatar May 02 '22 19:05 vidski

image

vidski avatar May 02 '22 19:05 vidski

Is there a reason to sanitize the column at all? In the postgrest-js client all we do is remove whitespaces.

vidski avatar May 02 '22 19:05 vidski

Is there a reason to sanitize the column at all? In the postgrest-js client all we do is remove whitespaces.

Column names can contain postgrest special characters which need to be escaped. The js client errors out because of this; see supabase/postgrest-js#262

Are you sure you are on the latest version though? The code in that screenshot doesn't look like it is from the latest version Can you make sure you are using supabase-py 0.5.5 (postgrest-py 0.10.1 or greater)?

anand2312 avatar May 03 '22 07:05 anand2312

I'm fine with escaping ',:()', but escaping '.' results in a wrong behaviour which makes it impossible to filter on foreign columns.

eq('table_a.table_b.id', my_id) will currently resolve to "table_a.table_b.id", but should resolve to "table_a"."table_b"."id". Maybe we should first split the column by '.', escape each item, and join using '.'.

This is using supabase-py 0.5.5 and postgrest-py 0.10.2

vidski avatar May 03 '22 08:05 vidski

Example

vidski avatar May 03 '22 08:05 vidski

Yeah I get what you mean 👍🏼 this'll be fixed in the next release. Thanks for the report!

anand2312 avatar May 03 '22 15:05 anand2312