Skip to content

Commit

Permalink
a fix to the default conversion behavior from string to datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
tameralamiri committed Oct 19, 2021
1 parent b34597d commit 6884e0e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flask_fixtures/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ class JSONLoader(FixtureLoader):

def load(self, filename):
def _datetime_parser(dct):
# this function avoid the attempt to pass the value as datetime
# this attempts to pass as datetime cause conflict when a field type JSON
# and contain a field with a date.
for key, value in list(dct.items()):
if key.endswith("__ignore_dt_parse"):
dct.pop(key)
key = key.split("__ignore_dt_parse")[0]
dct[key] = value
continue
try:
dct[key] = dtparse(value)
except Exception:
Expand Down

0 comments on commit 6884e0e

Please sign in to comment.