sqldelight
sqldelight copied to clipboard
Can't cast to Boolean when using IFNULL or COALESCE
SQLDelight Version
2.0.2
Operating System
macOS 14.6.1
Gradle Version
8.8
Kotlin Version
1.9.24
Dialect
sqlite-3-18
AGP Version
8.4.2
Describe the Bug
I have a query where I return fields from join'ed tables. Fields from joined table considered as nullable, and I want to return only not nullable values. So I want to convert Boolean?
to Boolean
with IFNULL(field, 0)
or COALESCE(field, 0)
. But instead of Boolean
I'm getting Long
even when I'm specifying AS Boolean
.
Tables:
CREATE TABLE Notification (
id TEXT PRIMARY KEY NOT NULL,
);
CREATE TABLE NotificationReadStatus (
id TEXT PRIMARY KEY NOT NULL,
read INTEGER AS Boolean NOT NULL
);
Query:
SELECT
Notification.id,
COALESCE(NotificationReadStatus.read, 0) AS Boolean
-- OR
IFNULL(NotificationReadStatus.read, 0) AS Boolean
FROM Notification
LEFT JOIN NotificationReadStatus ON Notification.id == NotificationReadStatus.id;
Think it's related to #3572.
Stacktrace
No response
Gradle Build Script
No response