Skip to content

COALESCE regression #4870

@vanniktech

Description

@vanniktech

SQLDelight Version

2.0.1

Operating System

Mac

Gradle Version

8.5

Kotlin Version

1.9.21

Dialect

sqlite

AGP Version

8.1.4

Describe the Bug

Table:

CREATE TABLE meditationPhase (
  id TEXT NOT NULL PRIMARY KEY,
  meditationId TEXT NOT NULL REFERENCES meditation(id),
  number INTEGER AS Int NOT NULL,
  duration INTEGER NOT NULL,
  sound TEXT AS Sound NOT NULL
);

and my query:

totalDuration:
SELECT COALESCE(SUM(duration), 0) AS totalDuration
  FROM meditationPhase;

With 2.0.0 it simply returned the value as Long?, now it is wrapped in a class:

public data class TotalDuration(
  public val totalDuration: Long?,
)

Is there any reason for this change? In addition, the type should really be Long since the 0 will always match and make the expression non-nullable.

Stacktrace

No response

Gradle Build Script

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions