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

Sum function fails in many use cases #1605

Open
alsundukov opened this issue Jan 5, 2023 · 1 comment
Open

Sum function fails in many use cases #1605

alsundukov opened this issue Jan 5, 2023 · 1 comment

Comments

@alsundukov
Copy link
Contributor

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.

@gangadhargo
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants