Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanitize_param() not correctly resolving when using nested columns #189

Closed
vidski opened this issue May 2, 2022 · 8 comments
Closed

sanitize_param() not correctly resolving when using nested columns #189

vidski opened this issue May 2, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@vidski
Copy link

vidski commented May 2, 2022

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
Copy link
Author

vidski commented May 2, 2022

image

@vidski
Copy link
Author

vidski commented May 2, 2022

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

@anand2312
Copy link
Contributor

anand2312 commented May 3, 2022

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 anand2312 added the bug Something isn't working label May 3, 2022
@vidski
Copy link
Author

vidski commented May 3, 2022

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
Copy link
Author

vidski commented May 3, 2022

Example

@anand2312
Copy link
Contributor

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

@J0
Copy link
Contributor

J0 commented Jan 23, 2023

Moving to the postgrest-py repo

@J0 J0 transferred this issue from supabase/supabase-py Jan 23, 2023
@anand2312
Copy link
Contributor

Fixed by #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants