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

ResultSet - Null integer columns returned as a zero #94

Closed
dash- opened this issue Feb 22, 2016 · 6 comments
Closed

ResultSet - Null integer columns returned as a zero #94

dash- opened this issue Feb 22, 2016 · 6 comments

Comments

@dash-
Copy link
Contributor

dash- commented Feb 22, 2016

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

CraZySacX added a commit that referenced this issue Feb 22, 2016
Feature 94 - Solution to Issue #94
@CraZySacX
Copy link
Owner

Merged. Closing.

@dash-
Copy link
Contributor Author

dash- commented Feb 25, 2016

I'd like to request a npm publish fairly soon. I'm about to release
node-waterline-derby, a waterline adapter for Derby, and it depends on the
newest changes in node-jdbc.

:-)

On Mon, Feb 22, 2016 at 4:30 PM, Jason Ozias [email protected]
wrote:

Merged. Closing.


Reply to this email directly or view it on GitHub
#94 (comment).

@CraZySacX
Copy link
Owner

Sure. Bumping to 0.2.0 due to API changes.

@dash-
Copy link
Contributor Author

dash- commented Feb 25, 2016

Thanks!

On Thu, Feb 25, 2016 at 9:38 AM, Jason Ozias [email protected]
wrote:

Sure. Bumping to 0.2.0 due to API changes.


Reply to this email directly or view it on GitHub
#94 (comment).

@CraZySacX
Copy link
Owner

Done

@EmilCernega
Copy link

Hello,
This issue appears again after commit 10a1928
this was changed:

               - if(type === 'BigDecimal') type = 'Int';
               + if (type === 'BigDecimal') type = 'Double';

But the if condition didn't change:

 if (type === 'Int' && _.isNull(self._rs.getObjectSync(cmd.label))) {
                    result[cmd.label] = null;
                    return;
                  }

Thank you,
Emil

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

No branches or pull requests

3 participants