Skip to content

No values returned when one item is missing using slices to get a subset of the data #94

Description

@girardinsamuel

When using slices without missing data it works perfectly:

data = dotty(
    {
        "users": [
            {"first_name": "Sam", "last_name": "Gamji"},
            {"first_name": "John", "last_name": "Doe"},
            {"first_name": ""}
         ]
    }
)

data.get("users.*.first_name") #== ["Sam", "John", ""]

But with one missing item in the subset it returns just None:

data = dotty(
    {
        "users": [
            {"first_name": "Sam", "last_name": "Gamji"},
            {"last_name": "Doe"},
            {"first_name": ""}
         ]
    }
)

data.get("users.*.first_name") #== None

I would expect to get:

data.get("users.*.first_name") #== ["Sam", None, ""]

Is it wanted ? Is it a bug ?

It would be really nice to have this behaviour !
Thanks 🙏 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions