Skip to content
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

ObjectID is in uppercase #55

Closed
sneakywombat opened this issue Jan 11, 2013 · 5 comments
Closed

ObjectID is in uppercase #55

sneakywombat opened this issue Jan 11, 2013 · 5 comments

Comments

@sneakywombat
Copy link

When viewing records in mongohub, the ObjectIDs are displayed in uppercase...

"_id": { "$oid" : "50231B4F8BE6E4F1F2E7E24F" }

when viewing in the mongoshell, they are not in uppercase...

"_id" : ObjectId("50231b4f8be6e4f1f2e7e24f")

Altering the case causes unpredictable query results, particularly when using model tree query structures. http://docs.mongodb.org/manual/tutorial/model-tree-structures-with-ancestors-array/

This seems to be something of a display issue in the program so copying and pasting existing records becomes a chore because I then need to change all the upper case letters to lower case. Would you consider making this behavior an option that the user can toggle on and off? I am using an older mongo binary, 2.0.1, so perhaps this has something to do with the case.

@jeromelebel
Copy link
Owner

In the link, I don't see any mention about the object id case. For the string type, of course, the case is preserved. For object id type, I can't imagine the case matters since it's just binary.
In http://docs.mongodb.org/manual/core/object-id/ there is no information about the object id case.

Just to match the mongoshell behavior, I will change the object id case, when I will have time.

@sneakywombat
Copy link
Author

Correct, the link doesn't mention case, but the example was to demonstrate how some people use the hex version of that binary key in a weak, foreign key document relationship. Imagine this scenario: you double click a document to edit it and you want the hex version of that binary id. the UI and the mongo shell shows the hex version to the user, but we know it's actually a binary key. The mongo shell always shows this hex version in lower case. The UI, however, puts it into uppercase. If I wanted to copy that hex key using the UI and put it into a parent or ancestor key/val, I would need to manually change the case of each upper case letter. If I do not, any queries that match against it will fail. This is because all of the other libraries I use to interface with mongo always return the result of the object-id in lowercase. ABC != abc so to speak.

I agree that the case technically doesn't matter for the object-id, but when copying and pasting that hex value to another field that you later use as a relational value (and in the process becomes text), case does matter. If both the shell and the ui both had the same case, I wouldn't really care, but it makes it troublesome to go back and forth between the two.

Either way, I love your app and really appreciate that you've taken it over! the original author's app crashes so much it's pretty unusable.

cheers,

-j

@jeromelebel
Copy link
Owner

on objective-c driver:
[master 6409303] lower case for objectid #55
1 file changed, 1 insertion(+), 1 deletion(-)

on mongohub:
[master 9fc7b57] lower case for objectid #55
1 file changed, 1 insertion(+), 1 deletion(-)
[master 9c3b51e] lower case for objectid #55
1 file changed, 1 insertion(+)

@jeromelebel
Copy link
Owner

You can test it with 2.5.5 Please download this version here : https://mongohub.s3.amazonaws.com/MongoHub.zip

Please close this issue when it will work for you.

@virl
Copy link

virl commented Apr 23, 2013

+1 to issue. Java mongo driver and morphia ORM mapper both using lowercase ObjectId.

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

No branches or pull requests

3 participants