2

I am trying to process some data stored in MongoDB. These are integers packed in a byte string. Something of the form:

"touch_data" : "\u0000\u0000\u0000\u0000\u0000\u0000\u0000"

If I take this string and compute its length, mongo's js engine tells me its 0 instead of 7. I confirmed this by setting different values for touch data and computed its length:

hello => 5 he\0llo => 2

Any ideas on how I can read the 'complete' string?

user1151659
  • 132
  • 11
  • 3
    Looks like a [registered bug](https://jira.mongodb.org/browse/SERVER-3538). – Denys Séguret Dec 31 '13 at 12:46
  • 1
    Thanks for the link! . Though I still have no idea how to handle that in javascript. I dont know of any memcmp/strcmp type function in javascript. – user1151659 Dec 31 '13 at 13:06
  • More related to [this one](https://jira.mongodb.org/browse/SERVER-6646). Sadly, updating to version 2.4.8 didnt work either. Any ideas? – user1151659 Dec 31 '13 at 14:20
  • What version of MongoDB are you using, and how are you computing the length of the string? SERVER-1300 was fixed back in 1.9.1 (for 2.0 production release) and SERVER-6646 was fixed in 2.4.5 and 2.5.0 (for 2.6 production release). I haven't been able to reproduce the issue with your example string, eg: `\u0000\u0000\u0000\u0000\u0000\u0000\u0000'.length` is 7. – Stennie Jul 03 '14 at 14:13
  • sorry mate, I no longer have access to the codebase I was working on. – user1151659 Jul 22 '14 at 11:55

0 Answers0