rafaelwendel / phpsupabase

PHP Client to use Supabase
MIT License
187 stars 17 forks source link

500 error on ilike, like on some string #20

Closed AndreaHDC closed 1 year ago

AndreaHDC commented 1 year ago

Hello, I am getting a 500 error from Supabase on like, ilike query on some string, example: try{ $listClients = $query->select('') ->from('clients') ->where('department_name', 'ilike.%cal%') ->execute() ->getResult(); foreach ($listClients as $client){ $resp[] = $client; } } Same call is working if I change 'cal' to 'matt': try{ $listClients = $query->select('') ->from('clients') ->where('department_name', 'ilike.%matt%') ->execute() ->getResult(); foreach ($listClients as $client){ $resp[] = $client; } } I was able to make all string work adding urlencode at the ilike statement: try{ $listClients = $query->select('*') ->from('clients') ->where('department_name', urlencode('ilike.%cal%')) ->execute() ->getResult(); foreach ($listClients as $client){ $resp[] = $client; } } Is this a normal behaviour? I don't see in the documentation that urlencode must be used in the where statement using like. Thank you!

rafaelwendel commented 1 year ago

Hello @AndreaHDC ,

I did some tests here using the "ilike" operator and curiously only the (sub) string "%cal%" throws the 500 error. It must be some word reserved for Supabase. Even with wrong words (like "aksjhflkjsdhfl") it doesn't throw an exception. LOL

And indeed this error is handled when using the "urlencode" function.

Thank you for your contribution!

AndreaHDC commented 1 year ago

Glad I could contribute in some way! Library is awesome!