Skip to content

Commit

Permalink
Compatibility with mongo #29
Browse files Browse the repository at this point in the history
  • Loading branch information
imsamurai committed May 22, 2015
1 parent a10fdc0 commit 40a4c10
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Model/Behavior/ActiveRecordBehavior.php
Expand Up @@ -25,12 +25,15 @@ public function setup(Model $Model, $settings = array()) {
static $defaultFields = null;
if (is_null($defaultFields)) {
$schema = $Model->schema();
$defaultFields = array();
if ($schema) {
$defaultFields = array_combine(array_keys($schema), Hash::extract($schema, '{s}.default'));
} else {
$defaultFields = array();
foreach ($schema as $field => $options) {
$defaultFields[$field] = isset($options['default']) ? $options['default'] : null;
}
$defaultFields += array(
$Model->primaryKey => null
);
}

}
return $defaultFields;
}
Expand Down

0 comments on commit 40a4c10

Please sign in to comment.