Coalesce not working on SQLite #53320
Unanswered
agustinzamar
asked this question in
Q&A
Replies: 3 comments
-
Which DB? (MySQL, MariaDB, Postgres, SQL Server?) Also,
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I just tried using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
v11.14.0
PHP Version
8.3.12
Database Driver & Version
SQLite on Herd for macOS 1.11.1
Description
The functions
COALESCE
andIFNULL
do not work properly over SQLite databases.The raw SQL query provided by
$builder->ddRawSQL()
is corectly parsed like the example belowselect * from "products" where IFNULL(promotional_price, price) >= 100;
and it works just fine when ran directly against the DB.
For some reason it will return no results when the builder excecutes
Steps To Reproduce
Running a query like this one
$query->where(DB::raw('COALESCE(promotional_price, price)'), '>=', $priceFrom)
will return no results when using the sqlite driver but running the resulting raw query against the DB does work correctly
Using
$query->whereRaw('COALESCE(promotional_price, price) >= ?', [$priceFrom])
does not work either.Also querying it as a column and then running the where clause like
$query->selectRaw('COALESCE(promotional_price, price) as current_price')
and then$query->where('current_price', '>=', $priceFrom)
doesnt seem to workBeta Was this translation helpful? Give feedback.
All reactions