msavin / Mongol-meteor-explore-minimongo-devtools

In-App MongoDB Editor for Meteor (Meteor DevTools)
http://play.with.meteor.toys
824 stars 40 forks source link

Adding new array to doc using update corrupts a date #79

Closed dpatte closed 9 years ago

dpatte commented 9 years ago

My docs have two date fields, Submitted and Updated. If I use mongol and update a doc adding the following: "test": ["Line1","Line 2","Line 3"], and save, the first date is corrupted. Viewing in Mongol, dates seem to be displayed with an extra space at the end, but after updating, the first date no longer has the extra space and is corrupted when read.

dpatte commented 9 years ago

Is it possible that when doing an update using mongol, that the date in a doc is being converted from a Date type to a string type?

msavin commented 9 years ago

Yes, looping in @JackAdams since he manages the editable JSON package

JackAdams commented 9 years ago

Yes -- it's very possible that dates are being converted to strings, but it sounds like the "update-save" workflow is being used here, not the editable-json. Still, it's entirely possible that the editable-json is involved in the problem. I need to give date fields some more attention anyway, so I'll run some tests when I do that.

JackAdams commented 9 years ago

Just had a look at the editable-json code -- I think that's what's causing the problem. I'll work on a fix soon.

dpatte commented 9 years ago

Thanks!

msavin commented 9 years ago

@JackAdams how far away would a fix be? (I think the solution is to treat dates as a string.) The reason I ask is I'm getting ready to ship Mongol 1.1.0 soon and would like to have this fixed for the update.

JackAdams commented 9 years ago

I'll have a look at it later tonight.

JackAdams commented 9 years ago

Just checked it. The editable-json package is maintaining date types correctly. It's the original update-save workflow that's converting date types to strings.

msavin commented 9 years ago

Working on a fix...

msavin commented 9 years ago

Fixed in 1.0.90. Let me know if you have any issues.

dpatte commented 9 years ago

It looks like it is fixed. Thanks a lot. I don't seem to be able to use Mongol to fix the date fields that were originally corrupted, but I can use the Mongo command line for that of course.

msavin commented 9 years ago

It should parse them back as a date, unless something else was changed about them and they no longer parse as a date. Thanks for confirming it works for you.

Sent from my iPhone

On Jun 3, 2015, at 9:16 PM, David Patte notifications@github.com wrote:

It looks like it is fixed. Thanks a lot. I don't seem to be able to use Mongol to fix the date fields that were originally corrupted, but I can use the Mongo command line for that of course.

— Reply to this email directly or view it on GitHub.

dpatte commented 9 years ago

Fixing the corrupted dates: If I use the green fields, it doesn't seem to work. It does work if I use update/save but only if I set them to zero and save, then the date and save. Unfortunately, it also converts all non-string falsy fields to Jan 1 1970 at the same time

msavin commented 9 years ago

Epic fail. Working on a patch.

dpatte commented 9 years ago

It happens to the best of us :)

msavin commented 9 years ago

Patch up -> the fix is limited but should work in 'standard' cases.

dpatte commented 9 years ago

Thanks. I notice that falsy non-date fields are ok now. Thanks. But I still can't seem to change a date field that was corrupted with the original error. I will investigate further and if necessary open another issue with exact details.