Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor - P4
-
Resolution: Won't Fix
-
Affects Version/s: 1.0.6
-
Fix Version/s: None
-
Component/s: pecl-mongo
-
Labels:None
-
Environment:php 5.3.1 windows
mondo 1.0.6 driver
-
# Replies:1
-
Last comment by Customer:true
Description
php example:
$array = array('a', 'b', 'c');
unset($array[1]);
$document = array(
'embedded' => $array,
);
// assuming local
$mongo = new Mongo();
$mongo->test->test->insert($document);
mongodb result:
{ "_id" : ObjectId(...), "embedded" :
}
expected:
['a', 'c']
I'm not sure how checking is done at the moment by the driver, but at the point of insert, all keys of the array are still ints, even if they are not consecutive. So, perhaps the difference maker between an object and an array is whether the keys consist of all ints (array), or a mixture of ints and strings etc. (object).
My workaround for now is to use anything that will 'compact' the keys, like sort(), before inserting arrays.
I'm aware that people could argue for both behaviours, so I'm logging this bug with the following in mind:
- if you're not aware, make you aware of the issue
- if you are aware, to get a relatively final response logged in JIRA as to whether it will be changed, or if it's a wont-fix
- if it's a wont-fix, to obtain official recommendation of workaround
Attachments
Issue Links
- is duplicated by
-
PHP-1051 "$in needs an array" error when running find() against MongoDB 2.6
-
- Closed
-