Skip to content

add support for BIGINT UNSIGNED <--> java.math.BigInteger#3847

Merged
sougou merged 1 commit intovitessio:masterfrom
HubSpot:jdbc-bigint
May 1, 2018
Merged

add support for BIGINT UNSIGNED <--> java.math.BigInteger#3847
sougou merged 1 commit intovitessio:masterfrom
HubSpot:jdbc-bigint

Conversation

@tpetr
Copy link
Copy Markdown
Contributor

@tpetr tpetr commented Apr 19, 2018

This PR adds support for java.math.BigInteger to the Vitess JDBC driver:

  • Add support for BigInteger parameters in VitessPreparedStatements
  • Add an explicit getBigInteger() to VitessResultSet
  • Update unit tests to flex BigInteger for both classes.

@harshit-gangal @acharis

Signed-off-by: tpetr <tpetr@hubspot.com>
@harshit-gangal
Copy link
Copy Markdown
Member

Currently there are 3 way to use BigInteger.

setBigDecimal("mysql_bigIntCol", new BigDecimal("1234567890"))
setLong("mysql_bigIntCol", Long.parseLong("1234567890")) if value can fit within a long
setString("mysql_bigIntCol", "1234567890") to let the JDBC driver convert the string for you

Statement and PreparedStatement method does not allow any other way.

The method you have added will only be accessible if you type cast them into VitessStatement or VitessPreparedStatement.

Do you really need to add this or can you use the above way as workaround?


Comments from Reviewable

@tpetr
Copy link
Copy Markdown
Contributor Author

tpetr commented Apr 29, 2018

@harshit-gangal Apologies for the slow response. We need this because JDBI calls VitessPreparedStatement.setObject() to bind parameters when constructing a query. If one of the parameters is a BigInteger you currently get an exception like this:

java.sql.SQLException: Cannot infer the SQL type to use for an instance of java.math.BigInteger
	at io.vitess.jdbc.VitessPreparedStatement.setObject(VitessPreparedStatement.java:379)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setObject(HikariProxyPreparedStatement.java)
	at org.skife.jdbi.v2.ObjectArgument.apply(ObjectArgument.java:35)
	at org.skife.jdbi.v2.ColonPrefixNamedParamStatementRewriter$MyRewrittenStatement.bind(ColonPrefixNamedParamStatementRewriter.java:167)
	... 88 common frames omitted

@harshit-gangal
Copy link
Copy Markdown
Member

:lgtm:


Reviewed 4 of 4 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@acharis
Copy link
Copy Markdown
Contributor

acharis commented Apr 30, 2018

LGTM

@sougou sougou merged commit eee2aac into vitessio:master May 1, 2018
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

Successfully merging this pull request may close these issues.

4 participants