Skip to content
Snippets Groups Projects
Commit 0808974e authored by Marko Kuder's avatar Marko Kuder
Browse files

fix empty records when some columns are empty

parent 4c2468c2
No related branches found
No related merge requests found
...@@ -376,14 +376,14 @@ class DatastorePlugin(p.SingletonPlugin): ...@@ -376,14 +376,14 @@ class DatastorePlugin(p.SingletonPlugin):
records_format = data_dict.get(u'records_format') records_format = data_dict.get(u'records_format')
json_values = records_format in (u'objects', u'lists') json_values = records_format in (u'objects', u'lists')
for field_id in field_ids: for field_id in field_ids:
fmt = u'to_json({0})' if records_format == u'lists' else u'{0}' fmt = u"COALESCE(to_json({0}), json 'null')" if records_format == u'lists' else u'{0}'
typ = fields_types.get(field_id) typ = fields_types.get(field_id)
if typ == u'nested': if typ == u'nested':
fmt = u'({0}).json' fmt = u'({0}).json'
elif typ == u'timestamp': elif typ == u'timestamp':
fmt = u"to_char({0}, 'YYYY-MM-DD\"T\"HH24:MI:SS')" fmt = u"to_char({0}, 'YYYY-MM-DD\"T\"HH24:MI:SS')"
if json_values: if json_values:
fmt = u"to_json({0})".format(fmt) fmt = "COALESCE(to_json({0}), json 'null')".format(fmt)
elif typ.startswith(u'_') or typ.endswith(u'[]'): elif typ.startswith(u'_') or typ.endswith(u'[]'):
fmt = u'array_to_json({0})' fmt = u'array_to_json({0})'
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment