Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Garet's avatar
Level 3

Telescope shows query escaped incorrectly

Please observe the following query, equivelant to the user input being Crotchet's

Entity::selectRaw('MATCH (name, seo_title) AGAINST (?) AS relevance', ["Crotchet's"])->get();

Telescope shows the query as:

select
  MATCH (name, seo_title) AGAINST ('crotchet\'s') AS relevance
from
  `entities`
where
  `entities`.`deleted_at` is null

All good so far.

However, let's say the user input is entered as Crotchet\'s and for reasons unknown to us, the user has placed a slash before their apostrophe:

Entity::selectRaw('MATCH (name, seo_title) AGAINST (?) AS relevance', ["Crotchet\'s"])->get();

The query runs fine so I belive it is escaped correctly. However, Telescope reports the query as:

select
  MATCH (name, seo_title) AGAINST (
    'crotchet\\' s ') AS relevance from `entities` where `entities`.`deleted_at` is null

Actually this is wrong, and if you copy and paste the above directly into the database engine of your choice, it will come back as a syntax error. The correct query should actually be:

select
  MATCH (name, seo_title) AGAINST (
    'crotchet\\\'s') AS relevance from `entities` where `entities`.`deleted_at` is null

Is this simply a bug with Telescope and the way the output is presented? Or something I'm overlooking?

0 likes
0 replies

Please or to participate in this conversation.