postgrest-js
postgrest-js copied to clipboard
Escape special characters in column names
Bug report
While working on https://github.com/supabase-community/postgrest-py/pull/108 I found out that postgrest-js does not escape special characters in column names.
Describe the bug
Columns that have PostgREST special characters .,:() should be escaped by surrounding in double quote "; this is not done and results in an API error.
To Reproduce
const res = await client
.from("test")
.select("*")
.eq(':col.name', 1);
console.log(res);
results in error:
{
error: {
message: '"failed to parse tree path (:col.name)" (line 1, column 1)',
details: 'unexpected ":" expecting field name (* or [a..z0..9_])'
},
data: null,
count: null,
status: 400,
statusText: 'Bad Request',
body: null
}
Wrapping :col.name in double quotes before passing it to .eq works as expected.