-
-
Notifications
You must be signed in to change notification settings - Fork 159
Handle Postgrest special characters #164
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
Comments
That's odd, I tried to reproduce this with: $ npm run test:db
$ curl -s 'http://localhost:3000/users' -H 'Content-Type: application/json' -d '{"username":"file (1).jpg"}' And then: import { PostgrestClient } from '@supabase/postgrest-js'
const postgrest = new PostgrestClient('http://localhost:3000')
postgrest
.from('users')
.select()
.eq('username', 'file (1).jpg')
.then(({ data, error }) => console.log(data, error))
// prints:
// [
// {
// username: 'file (1).jpg',
// data: null,
// age_range: null,
// status: 'ONLINE',
// catchphrase: null
// }
// ] null Maybe the field actually has More generally re: quoting, there has been some problems when automatically escaping on special characters: #131, #149, though these are on column names rather than values. I suspect there are certain filters for which it's safe to automatically escape special characters for values, but I haven't found an obvious one yet. Another problem is |
Field does not have
Also this seems to be a regression. A previous version of postgrest-js handled this without issues. I can find out which version the regression happened if it helps. Edit: this was working in postgrest v0.22.0 and stopped working in v0.24.0 |
I see. I remember I removed quoting on I did some tests and it seems like always quoting makes it not match values that have $ curl -s 'http://localhost:3000/users' -H 'Content-Type: application/json' -d '{"username":"(\")"}' Then there's no way to match it. @steve-chavez any way to get around this? Niche case though... either way, I think it's acceptable to |
@soedirgo I can match a curl 'l:3000/projects?name=eq.(")'
[{"id":3432423,"name":"(\")","client_id":null,"earnings":100}]
-- or
curl "l:3000/projects?name=eq.(%22)"
[{"id":3432423,"name":"(\")","client_id":null,"earnings":100}] Not with
Rare case, but it can be filed as bug in the postgrest repo. (Won't work inside the |
Postgrest defines the some special characters which need to be handled separately.
This doesn't work
but double quoting the filter works.
It would be better if the library checks if filters have special characters and automatically adds the double quotes. It seems cleaner than handling it at an application level.
WDYT?
The text was updated successfully, but these errors were encountered: