Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Can't cast to Boolean when using IFNULL or COALESCE #5413

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

Open
p-dmitriy opened this issue Aug 20, 2024 · 0 comments
Open

Can't cast to Boolean when using IFNULL or COALESCE #5413

p-dmitriy opened this issue Aug 20, 2024 · 0 comments

Comments

@p-dmitriy
Copy link

p-dmitriy commented Aug 20, 2024

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

@p-dmitriy p-dmitriy added the bug label Aug 20, 2024
@JakeWharton JakeWharton removed the bug label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants