Skip to content

to_dict(skip_empty=False) doesn't work recursively #1577

Open
@sirloon

Description

@sirloon

Hi, consider the following document indexed on ES:

{'_id': 'id123',
 '_index': 'index123',
 '_source': {
  'one_field': {'entries': []},
 }
}

Calling to_dict(skip_empty=False) on the corresponding DSL Document created out of it will return:

{"one_field": {}}

instead of

{"one_field": {"entries": []}}

After few tests, I believe the issue comes from the fact the serialize() can sometimes call to_dict(), without passing skip_empty, ex: https://github.com/elastic/elasticsearch-dsl-py/blob/master/elasticsearch_dsl/field.py#L226

HTH. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions