Skip to content

Conversation

@ppanero
Copy link
Member

@ppanero ppanero commented Mar 16, 2022

closes #276


# Determine dump data type if not provided
if dump_type is None:
sa_field = getattr(record_cls.model_cls, model_field_name)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slint this is the "bug" @alejandromumo discovered. This variable is never used, we could potentitally just return it, but then we would lose the capability of custom serializations, which is what we (and in most of the cases want).

@ppanero ppanero requested a review from slint March 16, 2022 15:07
@ppanero
Copy link
Member Author

ppanero commented Mar 17, 2022

Discussed IRL, check if it can be achieved with ChoiceType in the _sa_type method.

* Test should fail, as it is not allowed to load/dump with different
types.
assert isinstance(dumped_data["test"], str)
# Deserialize
loaded_data = dumper.load(dumped_data, TestRecord)
assert isinstance(loaded_data.test, EnumTestModel)
Copy link
Member

@alejandromumo alejandromumo Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently failing, as the data is being loaded as a str and not EnumTestModel. That happens because record's ModelField test has the attribute dump_type set to str when instantiated. Therefore, the load_type will be also set to str and does not allow the dumper to infer the load type from the record's model SQL Alchemy column type.

See dumper's load module field:

# Retrieve the value
val = dump.pop(dump_key)
# Return None values immediately.
if val is None:
return val
# Determine dump data type if not provided
if load_type is None:
load_type = self._sa_type(record_cls.model_cls, model_field_name)
# Deserialize the value
return self._deserialize(val, load_type)

Copy link
Member Author

@ppanero ppanero Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, this is an issue with the master branch, independently of the previous commit or not (dump_type parameter rename to load_type).

@ppanero
Copy link
Member Author

ppanero commented Mar 23, 2022

This is still relevant for consitency. However, the pid status got dropped from the implementation so we do not need it even in the far future. Might be shelvable

@lnielsen
Copy link
Member

@alejandromumo Can you check if this is still needed? If yes, add it to our ops board to work merge an integrate, and if not simply close.

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.

ElasticsearchDumper loading types

3 participants