[SERVER-14315] mongoimport doesn't support $maxKey and $minKey extended JSON Created: 19/Jun/14  Updated: 11/Jul/16  Resolved: 25/Jun/14

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.6.2
Fix Version/s: 2.7.3

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Shaun Verch
Resolution: Done Votes: 0
Labels: cap-ticket-needed, community-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File mongoimport.txt    
Issue Links:
Tested
Operating System: ALL
Steps To Reproduce:

> mongoimport -d test -c test mongoimport.txt

Sprint: Server 2.7.3
Participants:

 Description   

When importing the following file using mongoimport:

{ _id : 1, x : { $maxKey : 1 } }
{ _id : 2, x : { $minKey : 1 } }

mongoimport does not appear to be processing the $maxKey and $minKey extended JSON syntax correctly.

It's hard to tell using the shell:

> db.test.find()
{ "_id" : 1, "x" : { "$maxKey" : 1 } }
{ "_id" : 2, "x" : { "$minKey" : 1 } }
>

but the x values are actually nested documents, and not MaxKey and MinKey respectively.



 Comments   
Comment by Githook User [ 25/Jun/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-14315 Support MinKey and MaxKey extended JSON objects in JSON parser
Branch: master
https://github.com/mongodb/mongo/commit/caa0432e6e3f3f5355dcedbc2352625b07453435

Comment by Shaun Verch [ 19/Jun/14 ]

Ah, my mistake. I was using "MinKey()" rather than "MinKey" which apparently converts it to a string first. Thanks!

Comment by Robert Stam [ 19/Jun/14 ]

This is what I got:

c:\mongodb\mongodb-win32-x86_64-2008plus-2.6.2\bin>mongoexport -d test -c test
connected to: 127.0.0.1
{ "_id" : 1, "x" : { "$maxKey" : 1 } }
{ "_id" : 2, "x" : { "$minKey" : 1 } }
exported 2 records
 
c:\mongodb\mongodb-win32-x86_64-2008plus-2.6.2\bin>

But this isn't using the same collection that is the result of the mongoimport test...

I created these values using the shell, to ensure that the x values are real MaxKey and MinKey values:

> db.test.insert({ _id : 1, x : MaxKey })
WriteResult({ "nInserted" : 1 })
> db.test.insert({ _id : 2, x : MinKey })
WriteResult({ "nInserted" : 1 })
> db.test.find()
{ "_id" : 1, "x" : { "$maxKey" : 1 } }
{ "_id" : 2, "x" : { "$minKey" : 1 } }
>

Comment by Shaun Verch [ 19/Jun/14 ]

Hi rstam, I get this from mongoexport:

{ "_id" : { "$oid" : "53a33bc32a2475e2a682fe89" }, "a" : "{ \"$minKey\" : 1 }" }

It looks like it's dumping an escaped "minKey object" as a string rather than a sub object. Are you getting something different? If not, this looks like a bug in mongoexport as well.

Comment by Robert Stam [ 19/Jun/14 ]

Note that mongoexport seems to be doing the right thing, exporting MaxKey and MinKey using the correct extended JSON format.

It's only mongoimport that seems to not know about $maxKey and $minKey.

Generated at Thu Feb 08 03:34:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.