Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

fix(cursor): do not truncate an existing Long #441

Merged
merged 1 commit into from Jun 13, 2019

Conversation

jasontho-ms
Copy link

This is a fix for issue #440

@daprahamian
Copy link
Contributor

@jasontho-ms are you sure this is necessary? I just ran the following in the terminal and it seems okay.

const bson = require('bson');
const assert = require('assert');

assert.ok(bson.Long.fromNumber(bson.Long.MAX_VALUE).equals(bson.Long.MAX_VALUE))

@jasontho-ms
Copy link
Author

MAX_VALUE has no low bits so it works, but try it with one less than MAX_VALUE so it has low bits:

bson.Long.MAX_VALUE.toString()
'9223372036854775807'
const foo = bson.Long.fromString('9223372036854775806')
foo
Long { bsontype: 'Long', low: -2, high_: 2147483647 }
assert.ok(bson.Long.fromNumber(foo).equals(foo))
AssertionError [ERR_ASSERTION]: false == true

@daprahamian
Copy link
Contributor

@jasontho-ms Ah, good point.

Copy link
Contributor

@daprahamian daprahamian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this @jasontho-ms. As a heads up, we have merged mongodb-core and node-mongodb-native together for our next minor release. I can take care of porting this over to the new version, but you will lose credit for the commit. Do you want to take care of making this PR against the next branch of node-mongodb-native, or would you like me to take care of it. Let me know which works best.

- Dan

@jasontho-ms
Copy link
Author

jasontho-ms commented Jun 12, 2019 via email

@daprahamian daprahamian merged commit cc26b16 into mongodb-js:master Jun 13, 2019
@daprahamian
Copy link
Contributor

Merged. Thank you for the contribution @jasontho-ms!

daprahamian added a commit to mongodb/node-mongodb-native that referenced this pull request Jun 13, 2019
daprahamian added a commit to mongodb/node-mongodb-native that referenced this pull request Jun 13, 2019
daprahamian added a commit to mongodb/node-mongodb-native that referenced this pull request Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants