MongoHub-Mac icon indicating copy to clipboard operation
MongoHub-Mac copied to clipboard

DECIMAL columns are imported as String from MySQL

Open joarobles opened this issue 9 years ago • 1 comments

When importing from a MySQL table DECIMAL columns are imported as String despite of their lenght.

As a workaround I had to perform a manual conversion like this:

db.collection.find().forEach(function (p) {
  db.collection.update({_id: p._id}, { 
    $set: { 
      field: parseFloat(p.field)
    }
  });
});

joarobles avatar Sep 25 '15 18:09 joarobles

There is no concept of a decimal in mongodb. Once you convert to a float, you could have rounding issues since a double / float is not exact.

joefeser avatar Mar 10 '16 14:03 joefeser