Skip to content

Commit 0909c95

Browse files
fix bugs for date time field when using usjon
1 parent 80d1d4a commit 0909c95

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

es_sync/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def encode_in_py2(s):
2121
import signal
2222
import requests
2323
import subprocess
24-
import ujson
24+
import json
2525
import logging
2626
import shlex
2727
import datetime
@@ -198,17 +198,17 @@ def _processor(self, data):
198198
item['doc'].pop(field)
199199
except KeyError:
200200
pass
201-
meta = ujson.dumps({item['action']: action_content})
201+
meta = json.dumps({item['action']: action_content})
202202
if item['action'] == 'index':
203-
body = ujson.dumps(item['doc'])
203+
body = json.dumps(item['doc'], default=self._json_serializer)
204204
rv = meta + '\n' + body
205205
elif item['action'] == 'update':
206-
body = ujson.dumps({'doc': item['doc']})
206+
body = json.dumps({'doc': item['doc']}, default=self._json_serializer)
207207
rv = meta + '\n' + body
208208
elif item['action'] == 'delete':
209209
rv = meta + '\n'
210210
elif item['action'] == 'create':
211-
body = ujson.dumps(item['doc'])
211+
body = json.dumps(item['doc'], default=self._json_serializer)
212212
rv = meta + '\n' + body
213213
else:
214214
logging.error('unknown action type in doc')
@@ -322,9 +322,9 @@ def _parse_table_structure(self, data):
322322
serializer = float
323323
elif 'datetime' in type:
324324
if '(' in type:
325-
serializer = lambda x: datetime.datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f').isoformat()
325+
serializer = lambda x: datetime.datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f')
326326
else:
327-
serializer = lambda x: datetime.datetime.strptime(x, '%Y-%m-%d %H:%M:%S').isoformat()
327+
serializer = lambda x: datetime.datetime.strptime(x, '%Y-%m-%d %H:%M:%S')
328328
elif 'char' in type:
329329
serializer = str
330330
elif 'text' in type:

0 commit comments

Comments
 (0)