dtoubelis / sails-cassandra

Cassanda database adapter for Sails.js
MIT License
26 stars 11 forks source link

Urgent: comparing the value with the type 'long' doesn't work #40

Closed SergeyJyravlev closed 7 years ago

SergeyJyravlev commented 7 years ago

Hi!

`

var ret = value;

if (value instanceof Uuid) {
  ret = value.toString();
}
else if (value instanceof InetAddress) {
  ret = value.toString();
}
else if (value instanceof Integer) {
  ret = value.toNumber();
}
else if (value instanceof BigDecimal) {
  ret = value.toNumber();
}
else if (value instanceof Long) {
  ret = value.toNumber();
}
else if (value instanceof LocalTime) {
  ret = value.getTotalNanoseconds();
}
else if (value instanceof LocalDate) {
  ret = value.date;
}
return ret;

}; if (value instanceof Array) { return value.map(cast); } else { return cast(value); } };

`

This part of code "value instanceof Long" doesn't work at all.

if (Long.isLong(value)){ ret = value.toNumber(); }

This condition is executed correctly.

sails-cassandra - version 0.12.8

Please, resolve this issue ASAP.

Thanks!

dtoubelis commented 7 years ago

What is your environment? Can you provide more details? I.e. node.js version, cassandra-driver version, any relevant code sample.

SergeyJyravlev commented 7 years ago

+-- sails-cassandra@0.12.8 | +-- async@2.1.5 | +-- long@3.2.0 | +-- mocha@3.2.0 | | +-- browser-stdout@1.3.0 | | +-- diff@1.4.0 | | +-- glob@7.0.5 | | | +-- fs.realpath@1.0.0 | | | +-- inflight@1.0.6 | | | +-- minimatch@3.0.3 | | | -- once@1.4.0 | | +-- growl@1.9.2 | | +-- json3@3.3.2 | | +-- lodash.create@3.1.1 | | | +-- lodash._baseassign@3.2.0 | | | | +-- lodash._basecopy@3.0.1 | | | |-- lodash.keys@3.1.2 | | | | +-- lodash._getnative@3.9.1 | | | | +-- lodash.isarguments@3.1.0 | | | | -- lodash.isarray@3.0.4 | | | +-- lodash._basecreate@3.0.3 | | |-- lodash._isiterateecall@3.0.9 | | -- supports-color@3.1.2 | |-- has-flag@1.0.0 | +-- semver@5.3.0 | -- through2@2.0.3 |-- readable-stream@2.2.6 | +-- buffer-shims@1.0.0 | +-- process-nextick-args@1.0.7 | -- util-deprecate@1.0.2 -- uuid-1345@0.99.6 This dependences installed with sails-cassandra 0.12.8 Cassandra version 3.0.0 Node.js version 5.11.0

SergeyJyravlev commented 7 years ago

I find this issue after execute findOne function for model.

Model.findOne({id: id}).then(function (item) { console.log(item.state) // state: { low: 1, high: 0, unsigned: false }, })

dtoubelis commented 7 years ago

I think I know where this problem is coming from. The old driver did not have its own Long type and used the generic one.

Can you try chanhing line 9 in lib/utils.js from:

  Long = require('long');

to

  Long = types.Long;

if this works I'll fix it properly and create a unit test for it.

SergeyJyravlev commented 7 years ago

Yes, this works. Please fix this asap, because the module is used for the project and this issue is critical. Please, specify when this issue is solved. Thank you!

dtoubelis commented 7 years ago

I'll push the new version in about 12 hours. Traveling.

SergeyJyravlev commented 7 years ago

Thank you. I will be wait update.

dtoubelis commented 7 years ago

Pushed to npm. Please verify.

SergeyJyravlev commented 7 years ago

It's work. Thank you!

dtoubelis commented 7 years ago

👍