Blazer - Escape Characters

183 Views Asked by At

I feel like I am missing something, but I could not find it in the documentation on GH.

What are the escape characters for Blazer when searching in a string that contains a ' or ".

Example:

SELECT * FROM "search_filters" 
where "params" like '%with_vehicles_id"=>[%'
LIMIT 100

Update: The underlying database is Postgres 11. This is a blazer tool question, as the query above works just fine in a tool like dBeaver, or console. For some reason, I believe this is related to how Blazer is parsing the query before it is sent.

1

There are 1 best solutions below

6
On

I'm not very familiar with Blazer but it looks like it's a BI tool that lets your run SQL queries against your database and there's a playground here.

For PostgreSQL you don't need to do anything special for a double-quote inside of single quotes. The query as you wrote it would execute in a postgres terminal and the same approach works in the blazer playground.

SELECT * FROM "search_filters" 
where "params" like '%text"text%'
LIMIT 100

To query on a string that includes a single quote, PosgreSQL has you use two sequential single quotes, like this:

SELECT * FROM "search_filters" 
where "params" like '%text''text%'
LIMIT 100

Here's a link with more information: https://www.prisma.io/dataguide/postgresql/short-guides/quoting-rules

-- UPDATE --

Based on your error message ("syntax error at or near "LIMIT" LINE 3: LIMIT 100 LIMIT 1000") it looks like there are two "LIMIT" clauses being added to the SQL query. Do you have gems/plugins that are modifying the query and is there a way to disable them to see if that's causing the problem?