mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fixed yii\mongodb\ActiveRecord
saves null
as _id
, if attributes are empty
This commit is contained in:
@ -222,7 +222,9 @@ abstract class ActiveRecord extends BaseActiveRecord
|
||||
if (empty($values)) {
|
||||
$currentAttributes = $this->getAttributes();
|
||||
foreach ($this->primaryKey() as $key) {
|
||||
$values[$key] = isset($currentAttributes[$key]) ? $currentAttributes[$key] : null;
|
||||
if (isset($currentAttributes[$key])) {
|
||||
$values[$key] = $currentAttributes[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
$newId = static::getCollection()->insert($values);
|
||||
|
@ -4,6 +4,7 @@ Yii Framework 2 mongodb extension Change Log
|
||||
2.0.1 under development
|
||||
-----------------------
|
||||
|
||||
- Bug #6026: Fixed `yii\mongodb\ActiveRecord` saves `null` as `_id`, if attributes are empty (klimov-paul)
|
||||
- Enh #3855: Added debug toolbar panel for MongoDB (klimov-paul)
|
||||
- Enh #5592: Added support for 'findAndModify' operation at `yii\mongodb\Query` and `yii\mongodb\ActiveQuery` (klimov-paul)
|
||||
|
||||
|
Reference in New Issue
Block a user