Skip to content

Support key as integer for the maps put. #13

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Support key as integer for the maps put. #13

wants to merge 1 commit into from

Conversation

zhuangsirui
Copy link
Contributor

Support key as integer for the maps put. Add test case at bson_tests:maps_put_test/0.

@comtihon
Copy link
Owner

I don't like it.
The idea is, that you get what you put, so if you put #{1024 => <<"integer">>} - you shoud get #{1042 := <<"integer">>} from bson. Not #{<<"1024">> => <<"integer">>}.
For quick I can advice you to turn integer keys to binaries outside bson, because it is not bson-related question.
Also, if you are using just bson and want this function - you should add ability to receive integer keys as well. But - if you are using bson with mongodb - this will not work, as mongo do not like integer keys.

@zhuangsirui
Copy link
Contributor Author

I don't think this will be a problem.
Because now when I put #{atom => <<"atom">>} - I get #{<<"atom">> => <<"atom">>} as same as the integer.
The BSON key only can be a string when I decode from a BSON, this is the BSON problem. But I think when I encoding something in a specified language, the library should take care of this stuff.
I really want you to take this PR, but it's fine if you still don't like it. I'm just do this thing outside BSON :(

@comtihon
Copy link
Owner

atom was left for old driver versions, which use atom keys, not to break them. I plan to remove it in future.

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

Successfully merging this pull request may close these issues.

2 participants