-
Notifications
You must be signed in to change notification settings - Fork 268
Closed
Labels
Description
Not sure if the library is at fault or ext-mongodb 1.1.7, but field names with dots should generate a MongoException regardless of depth of array in which they are found, since mongo 3.x no longer allows dots in field names.
This issue was identified when we attempted to incorrectly insert documents with dots in field names.
For example, this will insert into mongo 3.x:
$data = [
"abc" => [
"Leather.CPO.Nametag" => 1
]
];
$collection->insertOne($data);
{
"_id" : ObjectId("57589f59ae8c50f34f8b4567"),
"abc" : {
"Leather.CPO.Nametag" : NumberLong(1)
}
}
If the array is 1 level, then insert like below will fail properly:
$data = [
"Leather.CPO.Nametag" => 1
];
$collection->insertOne($data);
PHP Fatal error: Uncaught exception 'MongoException' with message ''.' not allowed in key: Leather.CPO.Nametag' in -:12
Attempting shell insert when > 1 level deep does fail correctly though:
db.ezrshop_builders.insert(
... {
... "abc" :
... {
... "Leather.CPO.Nametag":1
... }
... }
... )
2016-06-08T15:46:02.984-0700 E QUERY Error: can't have . in field names [Leather.CPO.Nametag]