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

Percentage wildcard in like filter throws postgrest.exceptions.APIError #830

Closed
fschay opened this issue Jun 13, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@fschay
Copy link

fschay commented Jun 13, 2024

Bug report

Describe the bug

I use the like filter as described in the documentation. I get the following error postgrest.exceptions.APIError: {'message': 'JSON could not be generated', 'code': 500, 'hint': 'Refer to full message for details', 'details': ...

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

meeting_id = f'%{85770204020}%'
m = supabase.table('meeting').select('*').like('meeting_url', meeting_id).execute()

The meeting_url contains the meeting url with the meeting_id contained in the string.

Expected behavior

Should return the database entries, not throw an error. It seems for me an encoding error since if I replace the % with %25 no error is thrown.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: mac
  • Version of supabase-py: supabase==2.5.1
@fschay fschay added the bug Something isn't working label Jun 13, 2024
@fschay fschay changed the title Percentage wildcard in like filter cause postgrest.exceptions.APIError Percentage wildcard in like filter throws postgrest.exceptions.APIError Jun 13, 2024
@sulavpanthi
Copy link

sulavpanthi commented Jun 21, 2024

Hello fschay, I noticed a subtle issue in your query pattern syntax.

The pattern should not include {} braces around the value. Instead, directly use % symbols around the value to match any string containing 85770204020.

Here's the corrected code:

meeting_id = '%85770204020%' # Correct pattern syntax m = supabase.table('meeting').select('*').like('meeting_url', meeting_id).execute()

This should resolve the issue. For reference, you can also check the example from the Supabase documentation here.

If you have any further questions or issues, feel free to ask!

@fschay
Copy link
Author

fschay commented Jun 21, 2024

Ok thanks my bad.

@fschay fschay closed this as completed Jun 21, 2024
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

2 participants