ramses
ramses copied to clipboard
Some fields in event.fields are strings instead of the schematized type in after_* event handlers
Hi,
A boolean event.fields['field'].new_value is the wrong type in after_create (string instead of boolean).
Expected behavior:
event.fields['field'].new_value is a boolean in after_create.
Step to reproduce:
Example call:
http://localhost:6543/api/ressource/1?_m=PATCH&field=true
Field definition:
"field": {
"_db_settings": {
"type": "boolean",
"default": false
}
}
Processor:
@registry.add
def complete_task_if_everything_is_delegated(event):
if 'is_completed' in event.fields:
am_i_boolean = isinstance(event.fields['is_completed'].new_value, bool) # false, should be true
type_of_field = type(event.fields['is_completed'].new_value) # string, should be boolean
This is only happening when using get_tunnelling. This is because fields are passed as strings in url params.
@jstoiko I will experiment some more and get back to you on this. Thanks for the pointer.