postgrest-js icon indicating copy to clipboard operation
postgrest-js copied to clipboard

Escape special characters in column names

Open anand2312 opened this issue 3 years ago • 0 comments

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.

anand2312 avatar Apr 04 '22 10:04 anand2312