Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializable property is not filled when import data #598

Open
rcsalvador opened this issue Aug 7, 2019 · 0 comments
Open

Serializable property is not filled when import data #598

rcsalvador opened this issue Aug 7, 2019 · 0 comments

Comments

@rcsalvador
Copy link

I'm trying to use a class property with the @serializable decorator and a setter, like the sample below:

class Test(Model):

    field1 = StringType(serialized_name='u_field_1')
    _field2 = 'x'

    @serializable(type=StringType, serialized_name='u_field_2')
    def field2(self):
        return self._field2

    @field2.setter
    def field2(self, value):
        self._field2 = value

When I use the import_data() or create a class instance using the raw_data on __init__, the property is never set.

Looks like the atom_filter is not able to handle fields and properties at the same time.

When I specify the validate argument the property is loaded but the field is not.

test = Test()
test.import_data({'u_field_1': 'a', 'u_field_2': 'y'}, validate=False)  # this load the field1, but not the field2 
test.import_data({'u_field_1': 'a', 'u_field_2': 'y'}, validate=True)  # this ignore the field1, but load the field2
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

No branches or pull requests

1 participant