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

gocanto's avatar
Level 54

How do you test query to Json columns using sqlite?

Hey folks,

I came across an issue testing my queries using SQLite.

I need to perform query similar to

Product::whereRaw('features->"$.color"', 'red')->first();

This trows sintax error, but works with MySQL

Also, I tried the laravel docs way, like so:

 Product::where('features->color', 'red')->first()

but I get null as the result but works with MySQL

The issue here is I need to add tests for it and SQLite throws a syntax error.

Error trace:

PDOException: SQLSTATE[HY000]: General error: 1 near ">": syntax error
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 near ">": syntax error (SQL: select * from "products" where features->"$.color" limit 1)
0 likes
2 replies
oranzo's avatar

Hey! Have you found any solution to your issue? I am kind of in the same situation.

Please or to participate in this conversation.