ramses icon indicating copy to clipboard operation
ramses copied to clipboard

Some fields in event.fields are strings instead of the schematized type in after_* event handlers

Open oleduc opened this issue 10 years ago • 2 comments

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

oleduc avatar Nov 04 '15 21:11 oleduc

This is only happening when using get_tunnelling. This is because fields are passed as strings in url params.

jstoiko avatar Nov 19 '15 05:11 jstoiko

@jstoiko I will experiment some more and get back to you on this. Thanks for the pointer.

oleduc avatar Nov 19 '15 05:11 oleduc