[JAVA-21] Longs are not respected and are turned into doubles Created: 13/Aug/09 Updated: 02/Oct/09 Resolved: 14/Aug/09 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.8 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | John Carrino | Assignee: | Kristina Chodorow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
ByteEncoder.putNumber either ouputs ints or doubles. Small longs could be sent as ints, but Long values should also not be turned into doubles. |
| Comments |
| Comment by Kristina Chodorow (Inactive) [ 14/Aug/09 ] |
|
There's a new version of the Java driver (http://cloud.github.com/downloads/mongodb/mongo-java-driver/mongo-0.7.jar) which can save/retrieve longs. |
| Comment by John Carrino [ 13/Aug/09 ] |
|
Ok, cool. I was just following the getting stared guide which said to pick up the jar from If it isn't too much trouble, could to also post the source up in zip form, it makes it easier to dev against if I have source attached. Thanks! |
| Comment by Kristina Chodorow (Inactive) [ 13/Aug/09 ] |
|
Never mind, I didn't realize you were using the .6 driver. The 0.6 driver doesn't support longs, I'll release 0.7 asap. In the meantime, you could download the latest code from Github, if you wanted, which does support longs. |
| Comment by Kristina Chodorow (Inactive) [ 13/Aug/09 ] |
|
Yes. Also, I added: System.out.println(read.get("num").getClass()); which printed: class java.lang.Long |
| Comment by John Carrino [ 13/Aug/09 ] |
|
huh, I try it from the command line and it will accept all numbers up to max_long without converting it to a double. the posted unit test passes for you? |
| Comment by Kristina Chodorow (Inactive) [ 13/Aug/09 ] |
|
This works fine for me. Are you sure you're using a DB version that supports longs? DB support for longs was only added recently (post-0.9.7), can you try it with the nightly? |
| Comment by John Carrino [ 13/Aug/09 ] |
|
I had downloaded the latest on http://github.com/mongodb/mongo-java-driver/downloads Also to note is that the source version lags the jar. This is suboptimal when using source attachment for 0.6. |
| Comment by Eliot Horowitz (Inactive) [ 13/Aug/09 ] |
|
is this just an old jar? |
| Comment by John Carrino [ 13/Aug/09 ] |
|
I am using driver version 0.6. Here is a test that exposes the issue public void testObjectLong() { ByteEncoder encoder = ByteEncoder.get(); DBObject o = new BasicDBObject(); o.put( "num" , 517L ); encoder.putObject( o ); encoder.flip(); ByteDecoder decoder = new ByteDecoder( encoder._buf ); DBObject read = decoder.readObject(); assertEquals( 517L , read.get("num") ); } |