Skip to content

Postgres filters use incorrect escape characters #9989

@jmaslek-ica

Description

@jmaslek-ica

Describe the bug
In the postgres driver (newest - v1.3.72,, with Postgres 16.9) when using filters like contains or equals, the SQL is generated with ESCAPE '\\' . This results in an error:

 "error": "Error: syntax error at or near \")\"\n 

It seems that this is because there should be a single backslash.

To Reproduce
Steps to reproduce the behavior:
Create a postgres cube and execute a query using a contains filter.

Expected behavior
A clear and concise description of what you expected to happen.

We should be able to use contains/equals filters on a postgres connection.

Screenshots
If applicable, add screenshots to help explain your problem.

Minimally reproducible Cube Schema
In case your bug report is data modelling related please put your minimally reproducible Cube Schema here.
You can use selects without tables in order to achieve that as follows.

cube(`Users`, {
  sql: `
  SELECT 1 as id, 'john.doe@example.com' as email
  UNION ALL
  SELECT 2 as id, 'jane.smith@example.com' as email
  `,
  
  dimensions: {
    email: {
      sql: `email`,
      type: `string`
    }
  },
  
  measures: {
    count: {
      type: `count`
    }
  }
});

And then query with:

{
  "dimensions": ["Users.email"],
  "filters": [{
    "member": "Users.email",
    "operator": "contains",
    "values": ["example"]
  }]
}

Version:
Using 1.3.72 for the server/core/postgres-driver with Postgres 16.9

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

questionThe issue is a question. Please use Stack Overflow for questions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions