Skip to content

Using whereJsonContainsKey with Postgres breaks SQL formatting on Query Details page #1556

Open
@binaryfire

Description

@binaryfire

Telescope Version

5.2.6

Laravel Version

11.5

PHP Version

8.3

Database Driver & Version

Postgres 17

Description

The SQL displayed on the Query Details page is incorrect when using whereJsonContainsKey with Postgres. This might be due to the fact that Postgres uses ?? in the query.

Eg. if I use ->whereJsonContainsKey('metadata->preferences->notifications') and check $query->toSql() I see coalesce(("metadata"->'preferences')::jsonb ?? 'notifications', false), which is correct.

But in Telescope, the ?? is randomly replaced with values from other parts of the query:
image

The real SQL and query are correct. The problem is just with what Telescope is displaying.

Steps To Reproduce

Execute a query using whereJsonContainsKey and Postgres 17 and check the details in the Telescope dashboard.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions