-
Notifications
You must be signed in to change notification settings - Fork 90
Cast integer key to str if str key exist in dictionary #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cast integer key to str if str key exist in dictionary #167
Conversation
Cast integer key to str if str key exist in dictionary
Hi @jferreira-ca |
…to bugfix-int-dict-key
thanks @moomoohk. |
I've gone over your change and I'm not sure this patch is needed. While debugging the So I checked and the In the Instead of doing that, you could set Please let me know if this proposal solves your issue. |
It worked. Thanks for your support on that. I think we can close this PR then. |
sorry about that @moomoohk. I'm reopening it. The option works well if we are not using lists. But for our scenario we're using nested dicts and lists all together, on this case if we use that option it'll cause a TypeError. Example: actual: expected: |
I believe that problem can be overcome by using a custom creator function and passing it using the Please refer to this comment (the code there doesn't work in your specific case). |
Hi @jferreira-ca, |
Hey @moomoohk thanks for the response. Before open this PR we actually tested passing a new creator function, but for this scenario specifically it does not work. |
Could you please include some example code? (The creator that failed) |
Even passing a creator the code still breaks cause segments.set function still tries to access the node using the int key. |
@jferreira-ca I've pushed a small change to the branch |
Honestly I don't understand how a creator could help on this case. The problem happens when a dict has ant int key on it as str (e.g |
@jferreira-ca I've identified the issue. Please follow #169 for updates. I'm closing this PR. Regards. |
thanks!!! |
Fix for issue where we have a numeric key in dictionary that is a string, and dpath.util.new creates the same numeric key but as an integer.
Actual Result:
Expected Result: