-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Problem Description
mongodump --queryFile requires a vaild JSON input file. When a regex statement is formatted as valid JSON this fails since it is no longer a vaild JSON expression.
{{}}
Steps to Reproduce
Run mongodump with a query input file which contains a regex:
{{mongodump "mongodb+srv://$sourceCluster.$sourceProject.mongodb.net/" --username="$sourceUser" --password="$sourcePwd" --db <dbname> --collection <collection name> --queryFile ./queryfile.json --archive=collectionDump.dump }}
queryfile with a vaild query (tested in compass)
this file fails to run due to invalid JSON, the query it self is fully functioning in compass
{ "$or": [{
"devicemac":
{ "$regex": /^01:01:01:03:FF:/ } },{
"devicemac":
}]}
queryfile with a vaild JOSN
this file is processed to run but the end result is in incorrect
only change put the parameter for $regex into quotes. This makes it valid JSON but an invalid regex.
{ "$or": [{
"devicemac": {
"$regex": "/^01:01:01:03:FF:/"
}
},{
"devicemac":
}]}
Expected Results
mongodump should dump only these documents which fit to the query which was successfully tested in compass - this query is copied to a queryfile and passed to mongodump as parameter
Actual Results
the query with "$regex": /^01:01:01:03:FF:/ works correct in compass and provides a correct amount of documents but is not accepted from mongodump as valid JSON.