Skip to content

Sum function fails in many use cases #1605

Open

Description

@alsundukov

Hello @mathiasrw, @gangadhargo!
After the release of v2.2.2 with this commit the Sum formula has stopped working with many user cases:

`
//I changed a little test229.js for testing
...
alasql('insert into RunTotalTestData ([value]) values (1)');
alasql('insert into RunTotalTestData ([value]) values (2)');
...

SELECT SUM(IF(TRUE, a.[value], 0)) FROM RunTotalTestData a // return null

SELECT SUM(a.[value] + ";") FROM RunTotalTestData a // return null
`

Previously, it was possible to sum strings inside the Sum function, use IF, now this does not work.

Activity

  1. gangadhargo commented on Jan 5, 2023

    @gangadhargo
    Contributor

    @alsundukov Thanks for pointing that out.

    @mathiasrw what should be the behavior for the above two cases
    It seems the condition is wrong inside the sum for the first case the below one working fine.
    alasql('SELECT SUM(CASE WHEN TRUE THEN a.[value] ELSE 0 END) FROM RunTotalTestData a') = 3 this is fine.

    the second case, shouldn't we treat it as null if the value type is a number with special characters? In this case "3;"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions