hello everyone, i'm stuck with .sum() aggregate fu...
# exposed
p
hello everyone, i'm stuck with .sum() aggregate function. I have a column of type ushort and i have a query which should retrieve a sum of the column values. Even though the values are ushort (SMALLINT UNSIGNED) resulted sum might be out of the ushort range. And for plain MariaDB query in console it's absolutely legit query. But
MyTable.uShortCol.sum()
truncates result to ushort, obviously. Any adwise? I've found an issue on the GitGub https://github.com/JetBrains/Exposed/issues/1035 which seems relevant to me but there's no solution
i've managed to get a correct sum with
Copy code
MyTable.uShortCol.sum().castTo<Int>(IntegerColumnType())
And it's fine to me. But
Copy code
MyTable.uShortCol.sum().castTo<UInt>(UIntegerColumnType())
didn't work because generated SQL query was incorrect
Copy code
CAST(SUM(MyTable.uShortCol) AS INT UNSIGNED) b FROM
s
Why is that sql incorrect?
p
because of
UNSIGNED
inside the
CAST
. It throws mysql error in my case (MariaDB 10.10)
s
Looks like a bug in exposed