Closed dpatte closed 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?
Yes, looping in @JackAdams since he manages the editable JSON package
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.
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.
Thanks!
@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.
I'll have a look at it later tonight.
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.
Working on a fix...
Fixed in 1.0.90. Let me know if you have any issues.
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.
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.
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
Epic fail. Working on a patch.
It happens to the best of us :)
Patch up -> the fix is limited but should work in 'standard' cases.
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.
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.