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

[finagle-mysql] finagle-mysql 6.25.0: Can not read UNSIGNED INT columns correctly #438

Closed
fab-soundcloud opened this issue Nov 23, 2015 · 5 comments

Comments

@fab-soundcloud
Copy link

Given this table:

CREATE TABLE `batches` (
  `id`         INT UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  COLLATE = utf8_unicode_ci;

with this data:

INSERT INTO `batches` (`id`)
VALUES (4294967295);

Trying to load that row with finagle mysql via pseudo code:

PreparedStatementQuery("SELECT * FROM batches WHERE id = ?").select(4294967295L)

results in this value being available in the pattern matching:

IntValue(-1)

It looks like mysql-finagle does not understand UNSIGNED int's which should result in a LongValue() or at least a Long java/scala representation. It always parses an Int which MaxValue is:

scala> Int.MaxValue
res0: Int = 2147483647

The problematic code I guess is this:

https://github.com/twitter/finagle/blob/develop/finagle-mysql/src/main/scala/com/twitter/finagle/mysql/Row.scala#L74

Expected behaviuor would be the that I can successfully read the value 4294967295 back somehow.

@mosesn
Copy link
Contributor

mosesn commented Nov 23, 2015

@fab-soundcloud good catch! Unfortunately, we don't have a ton of bandwidth right now, but we'd love to shepherd your PR through 👍

@mehmetgunturkun
Copy link
Contributor

mehmetgunturkun commented May 9, 2017

Hi @mosesn, I am willing to solve this issue, now working on it.
Should it be assigned to me?

@mosesn mosesn assigned mosesn and unassigned mosesn May 9, 2017
@mosesn
Copy link
Contributor

mosesn commented May 9, 2017

@mehmetgunturkun it looks like I can only assign it to committers, but feel free to start working on it! I'll just mark it as "in progress". Thanks, and welcome to the project!

@mehmetgunturkun
Copy link
Contributor

Hi @mosesn, I guess I solved the issue but before creating a pull request there are several things that I want to ask:

  1. Should I talk to people in gitter.im about the way I solve the issue or these comments will be done in code review before the merger?
  2. In order to understand unsigned part, I used flags in the field data. There was no documentation for bits and their locations per each attribute in mysql side, so I dug into source code and find the bit masks for each attribute. I want to document this process and put a link to that source code so that nobody again needs to do this research. How should I do that?

P.S. Sorry if I shouldn't have written these into issueç

@kevinoliver
Copy link
Contributor

This got fixed a little while back. See this unit test for an example.

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

No branches or pull requests

4 participants