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 when using AS #4472

Closed
vanniktech opened this issue Jul 31, 2023 · 1 comment
Closed

Infer type in COALESCE when using AS #4472

vanniktech opened this issue Jul 31, 2023 · 1 comment
Labels

Comments

@vanniktech
Copy link
Contributor

vanniktech commented Jul 31, 2023

Description

Somewhat related issue: #3416

I have two tables:

import kotlin.time.Duration;

CREATE TABLE directory (
  id TEXT NOT NULL PRIMARY KEY,
  backgroundRefreshInterval INTEGER AS Duration
)

CREATE TABLE channel (
  id TEXT NOT NULL PRIMARY KEY,
  directoryId TEXT,
  backgroundRefreshInterval INTEGER AS Duration,
  FOREIGN KEY (directoryId) REFERENCES directory(id)
)

then I have my custom query:

backgroundRefreshIntervals:
SELECT COALESCE(directory.backgroundRefreshInterval, channel.backgroundRefreshInterval) AS backgroundRefreshInterval
  FROM channel
  LEFT JOIN directory
    ON channel.directoryId = directory.id
;

This is the generated class:

public data class BackgroundRefreshIntervals(
  public val backgroundRefreshInterval: Long?,
)

Although I'd really like to have:

-  public val backgroundRefreshInterval: Long?,
+  public val backgroundRefreshInterval: Duration?,
@vanniktech
Copy link
Contributor Author

Argh. This is a duplicate of #3572

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

No branches or pull requests

1 participant