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

Infer type in COALESCE #3416

Closed
vanniktech opened this issue Aug 6, 2022 · 1 comment · Fixed by #3431
Closed

Infer type in COALESCE #3416

vanniktech opened this issue Aug 6, 2022 · 1 comment · Fixed by #3431
Labels

Comments

@vanniktech
Copy link
Contributor

SQLDelight Version

2.0.0-alpha03

Operating System

Mac

Gradle Version

7.5.1

Kotlin Version

1.7.10

Dialect

sqlite

AGP Version

7.2.2

Describe the Bug

From: #3413 (comment)

it would be nice if sqldelight was able to infer the type of :refreshOnStartUp:

CREATE TABLE directory (
  id TEXT NOT NULL PRIMARY KEY,
  refreshOnStartUp INTEGER AS Boolean
);

CREATE TABLE channel (
  id TEXT NOT NULL PRIMARY KEY,
  refreshOnStartUp INTEGER AS Boolean,
  directoryId TEXT
);

myQuery:
SELECT channel.*
  FROM channel
  LEFT JOIN directory
    ON channel.directoryId = directory.id
  WHERE COALESCE(channel.refreshOnStartUp, directory.refreshOnStartUp, :refreshOnStartUp) = 1
;

Currently, one need to use CAST: CAST(:refreshOnStartUp AS INTEGER).

Stacktrace

No response

Gradle Build Script

No response

@hfhbd
Copy link
Collaborator

hfhbd commented Aug 11, 2022

Hm, I think, should it only be possible to infer the kotlin type, if all other parameters of the function have the same type:
MAX(Int, Int, ARG) = > Arg = Int. So MAX(Int, Text, ARG) = > error would result into an error, because the type is ambiguous.

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

Successfully merging a pull request may close this issue.

2 participants