Skip to content

Spaces are squeezed from column names when calling .select() #30587

@rickwargo

Description

@rickwargo

I am unable to specify column names that have spaces (an possibly other things) in a fetch statement. I do have a workaround, and that is to literally quote the column name in the args.

In the following example (yes, I know it just returns a bunch of nulls, if it worked), the generated API call fails when column contains a space.

      const {data, error} = await supabase
        .from(table_name)
        .select(column)
        .is(column, null);

For example, assuming the database had a table named "My Table" with a nullable column named "My Column", and the query specified table_name = "My Table" and column = "My Column", the resulting REST query is

https://xxxxxx.supabase.co/rest/v1/My%20Table?select=MyColumn&My+Column=is.null

The table name is correctly interpreted as case-sensitive with spaces, however, for the returned data, the column name is stripped of its space and it returns a 400 Bad Request HTTP error.

The error is:

{
  "code": "42703",
  "details": null,
  "hint": 'Perhaps you meant to reference the column "My Table.My Column".',
  "message": "column My Table.MyColumn does not exist"
}

I did not find in the API documentation where this behavior is specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternal-issueCreated outside of Supabasepr-openedA PR has been opened to resolve the issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions