4teamwork / ftw.solr

Solr integration for Plone
5 stars 5 forks source link

Fix rounding errors with DateTime milliseconds. #158

Closed deiferni closed 4 years ago

deiferni commented 4 years ago

When milliseconds of a DateTime are above 999500 python string formatting rounds up the value. This leads to an ISO 8601 date format strings with a value of 60 for the [ss] (second ) part. Solr considers such date format strings invalid and throws an error, e.g.:

Invalid Date in Date Math String:'2015-04-07T14:43:60.000Z'

This will result in the corresponding object not being indexed or updated in solr by ftw.solr.

With this PR we fix the issue by splitting the seconds part of a DateTime into separate seconds and milliseconds parts and also pass them as separate arguments to string formatting.

additionally i've reproduced the timestamp issue locally. i have verified that with this fix the solr error no longer pops up and bin/instance solr sync is successful and manages to update all objects in solr.

Fixes #157.

njohner commented 4 years ago

☠️ I'll quickly highjack this and modify the tests to my liking 😅