-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Unable to Decode sum(int(11)) Values in MySQL #18
Labels
bug
Something isn't working
Comments
thecheatah
changed the title
Issue decoding sum(
Unable to Decode sum(Mar 15, 2020
int_column
)column
) Values
thecheatah
changed the title
Unable to Decode sum(
Unable to Decode sum(Mar 16, 2020
column
) Valuescolumn
) Values in MySQL
The native D mysql driver seems to have run into a similar issue: mysql-d/mysql-native#39 |
thecheatah
changed the title
Unable to Decode sum(
Unable to Decode sum(int(11)) Values in MySQL
Mar 17, 2020
column
) Values in MySQL
newdecimal appears to be a length encoded string as documented here: https://mariadb.com/kb/en/resultset-row/#decimal-binary-encoding From observation a |
Example encoding of 1 as a new decimal
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not able to decode an integer for a query like
where
unread_messages_count
is anint(11)
in mysql. Going through the debugger, it seems that we hit thedefault
case on line 313 ofMySQLData.swift
.The value of
MySQLData.type
that the switch statement is switching off of has a raw value of246
. Type246
isnewdecimal
from MySQLProtocol+DataType.swift line 68. Should we handle convertingnewdecimal
toInt
? The default.sum()
aggregation function tries to decode toInt
as well and I was having trouble with the following code:I was getting the same decoding error as the raw query.
I can see why they might use decimal as the summed up columns might not be integers. Looking at the MySQLNIO decoding logic, it doesn't seem like we handle decoding of
newdecimal
anywhere.newdecimal
seems to be unimplemented.Also, does decoding sum as int by default make sense? (I can be convinced either way)This is dynamic based on the type of the field. The "issue" is that for an int column, mysql is returning anewdecimal
that cannot be parsed as an int.I am using the latest docker image for MySQL 5.7.
My work around for this bug was to cast the sum aggregate as
SIGNED
Added test case that fails:
Debugger returns
The text was updated successfully, but these errors were encountered: