Skip to content

values Dictionary should be checked for the existence of all names in dict, not equal length (if a check is even necessary) #144

@jsams

Description

@jsams

At this point in the processing of bind! when a user passes in a symbol dict for the values parameter, you are checking to make sure that the number of parameters is equal to the length of the dictionary. However, I think it is not an uncommon use-case to construct a slightly larger dict that gets passed to several different queries, not all of which need every element in the dict. A larger dict, from this view, is not an error.

I'm not sure a check is really necessary. While I'm not sure what the consequences of executing the various binds and then bailing is, you will end up with a KeyError and failing with a pretty interpretable error. If it doesn't screw with the state of the database, that seems like a perfectly reasonable failure mode to me.

But if you do need to check, the check should be that the names from the query are a subset of the keys of the dict, and not that the lengths are equal. There is no guarantee that the query names are in the dict names, so, the length isn't a particularly good guarantee.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions