Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
binaryfire opened this issue Dec 28, 2024 · 1 comment

Comments

@binaryfire
Copy link

binaryfire commented Dec 28, 2024

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.

@binaryfire binaryfire changed the title Using whereJsonContainsKey with Postgres breaks SQL formatting on the Query Details Using whereJsonContainsKey with Postgres breaks SQL formatting on Query Details page Dec 28, 2024
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants