mongoexport / mongoimport: Getting a Double instead of a Integer

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.0.7
    • Component/s: mongoexport, mongoimport
    • None
    • Environment:
      Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.68-1+deb7u3

      mongoexport version: 3.0.0
      mongoimport version: 3.0.0

      Hi Team,

      After doing a mongoexport and mongoimport like the next:

      mongoexport -h $src -d xxx -c $src_collectioName | mongoimport -h $trgt -d xxx -c $trgt_collectionName

      I am getting a ClassCastException. Impossible to cast a Double into a Integer.

      I think the bug is the next:

      I have an array of Integer in the source mongodb. It's a list of ages with a name of "children_ages".

      After doing the command to export and import the data in another mongodb, I am getting the same list, but the type is converted to Double instead of Integer as expected.

      Example of real data using the $type to be sure the type of the array is correct:

      SourceDb:

      hi1:PRIMARY> db.price_stats_20151226.find({_id:ObjectId("567f10bb53d1e64bb1bede00"),children_ages:{$type:16}})

      { "_id" : ObjectId("567f10bb53d1e64bb1bede00"), "sp_id" : "41-16767", "s_id" : "41-40439", "kw" : [ "pricekw52x2015" ], "price_per_night" : 0, "total_price" : 430.75, "adults" : 1, "children_ages" : [ 1, 1, 4, 6, 12, 13 ], "number_of_days" : 1, "creation_date" : ISODate("2015-12-26T22:11:51.896Z"), "arrival_day" : ISODate("2015-12-25T23:00:00Z"), "departure_day" : ISODate("2015-12-26T23:00:00Z") }

      This is just one document under the collection "price_stats_20151226" with an array children_ages with a type:16, that it is Integer. In the sourceDB for the Id: 567f10bb53d1e64bb1bede00 the "children_ages" is : [ 1, 1, 4, 6, 12, 13 ]

      After exporting and importing the data i get

      Destination DB

      > db.price_stats.find({_id:ObjectId("567f10bb53d1e64bb1bede00"),children_ages:{$type:1}})

      { "_id" : ObjectId("567f10bb53d1e64bb1bede00"), "adults" : 1, "arrival_day" : ISODate("2015-12-25T23:00:00Z"), "children_ages" : [ 1, 1, 4, 6, 12, 13 ], "creation_date" : ISODate("2015-12-26T22:11:51.896Z"), "departure_day" : ISODate("2015-12-26T23:00:00Z"), "kw" : [ "pricekw52x2015" ], "number_of_days" : 1, "price_per_night" : 0, "s_id" : "41-40439", "sp_id" : "41-16767", "total_price" : 430.75 }

      I am getting all the data for the Id: 567f10bb53d1e64bb1bede00, but the array "children_ages" with the same data is converted to a Double array when i was expecting the same Integer Array.

      Then I am getting this ClassCastException in my java application.

      Regards from Munich,

      Manuel

            Assignee:
            Gabriel Russell (Inactive)
            Reporter:
            msierra
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: