-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
ResultSet - Null integer columns returned as a zero #94
Comments
Merged. Closing. |
I'd like to request a npm publish fairly soon. I'm about to release :-) On Mon, Feb 22, 2016 at 4:30 PM, Jason Ozias [email protected]
|
Sure. Bumping to 0.2.0 due to API changes. |
Thanks! On Thu, Feb 25, 2016 at 9:38 AM, Jason Ozias [email protected]
|
Done |
Hello,
But the if condition didn't change:
Thank you, |
The implementation of ResultSet.toObjArray, ResultSet.toObject, and ResultSet.toObjectIter (the former two depending upon the latter), simply calls java.sql.ResultSet.getInt() [as _rs.getIntSync] for Integer values. Unfortunately, when databases have null values for integer columns, java.sql.ResultSet.getInt() returns 0. Which is definitely not the same as null, and the two cannot somehow later be separated. Zero and null are both separate necessary values.
This problem is solved in the Java world by calling java.sql.ResultSet.getObject() - and if the result is Null, it's null. Otherwise, you can either cast to Integer or call getInt() for the int value.
See: http://stackoverflow.com/questions/5881834/getting-integer-object-from-resultset
The text was updated successfully, but these errors were encountered: