Skip to content

Conversation

@SteadBytes
Copy link
Collaborator

@SteadBytes SteadBytes commented Mar 8, 2019

Issue #598

Implements a new dot_escape kwarg to fields.Raw to support '.' characters within a field name without using as a nesting separator.

Current behaviour:

>>> data = {"my.dot.field": 1234}
>>> model = {"my.dot.field: fields.Integer}
>>> marshal(data, model)
{"my.dot.field:": None}

New behaviour:

>>> data = {"my.dot.field": 1234}
>>> model = {"my\.dot\.field: fields.Integer(dot_escape=True)}
>>> marshal(data, model)
{"my.dot.field:": 1234}

>>> data = {"my.dot": {"field": 1234}}
>>> model = {"my\.dot.field: fields.Integer(dot_escape=True)}
>>> marshal(data, model)
{"my.dot.field:": 1234}

>>> data = {
        'address.country': 'UK',
        'address.postcode': 'CO1',
        'user.name': {
            'first': 'John',
            'last': 'Smith',
        }
    }

>>> model = {
        'address\.country': fields.String(dot_escape=True),
        'address\.postcode': fields.String(dot_escape=True),
        'user\.name.first': fields.String(dot_escape=True),
        'user\.name.last': fields.String(dot_escape=True),
    }

>>> marshal(data, model)
{'address.country': 'UK',
 'address.postcode': 'CO1',
 'user.name.first': 'John',
 'user.name.last': 'Smith'}

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 96.85% when pulling b30acdc on SteadBytes:field-key-dot-escape into a8f3582 on noirbizarre:master.

@dstrigl
Copy link

dstrigl commented Mar 26, 2019

Would be a nice feature!

@dstrigl
Copy link

dstrigl commented Jan 9, 2020

Any plans when if and when this feature will be implemented/merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants