You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.