Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

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

Open
oleduc opened this issue Nov 4, 2015 · 2 comments

Comments

@oleduc
Copy link
Contributor

oleduc commented Nov 4, 2015

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
@jstoiko
Copy link
Member

jstoiko commented Nov 19, 2015

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

@oleduc
Copy link
Contributor Author

oleduc commented Nov 19, 2015

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants