UnionOfRAD/lithium — pull request #313 by Daikoun (2012-02-06 10:56:28+00:00)
Title: Data: fixed & optimized conditional operation mapping, schema reference on Document->set() [second try]

Condition operation mapping:
=====================
The conditions mapping using operation did not worked properly.
If you define e.g. something like this:
```
group::count(array('_id' => array('$ne' => this->request->id))); //id is a string
```
in the mapped query the id remains as string, which looks like this:
```
'conditions' => array(
'_id' => array('$ne' => $id) //where $id represents the given id, which still remains as string
)
```

if I use the alias '!=' instead of the mongo operation '$ne':
```
group::count(array('_id' => array('!=' => this->request->id))); //id is a string
```
the id will be mapped but the query structure is not compatible to the mongo php driver:
```
'conditions' => array(
'_id' => array('$ne' => array('_id' => MongoId($id))) //where $id represents the given id string
)
```

The fix solves the compatibility bug no matter if the Mongo operation or the alias will be used and optimizes the operation mapping function.
Result:
```
'conditions' => array(
'_id' => array('$ne' => MongoId($id)) //where $id represents the given id string
)
```
Test cases are still implemented in MongoDbTest but failed in previous version.

Schema reference:
==============

If I set a value in a document like this:
```
$group->created = '';
```
and there is a schema defined in the specific model, like this
```
protected $_schema = array(
'created' => array('type' => 'date', 'default' => ''),
);
```
the value should be converted to the specified type, which did not happened caused by a wrong reference call to the schema of parent class Entity instead of the model.