Skip to content

Commit

Permalink
Missing property now throws an Exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Fanger committed May 17, 2013
1 parent 780c4ad commit f5ad64a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion classes/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,14 @@ protected function convertToInstance($data, $config, $index = null, $reload = fa
}
}
if (count($properties) !== 0) {
warning('Missing mapping for property: '.$config->class.'->'.human_implode(' and ', array_keys($properties)), 'Add "'.current(array_keys($properties)).'" to the ModelConfig->properties or to ModelConfig->ignoreProperties if the property wont be stored in the backend.');
$causes = array(
'1. The column is missing in the backend/database.',
'2. The relation/foreign key is missing in the backend/database.',
'3. The column has diffent name than the property. Set the ModelConfig->properties[columname] = propertyname.',
'4. The property should be ignored by the repository. Add the property to the ModelConfig->ignoreProperties.',
'5. The relation couldn\'t be detected. Add an entry to ModelConfig->hasMany or ModelConfig->belongsTo.'
);
throw new InfoException('Unexpected property: '.quoted_human_implode(' and ', array_keys($properties)).' in '.$config->class.' class for "'.$config->name.'"', '<b>Possible causes:</b><br />'.implode('<br />', $causes));
}
$this->validated[$config->name] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function test_missing_column() {
$repo->getCustomer(1);
$this->fail('The additional property/missing column should have given a notice.');
} catch (\Exception $e) {
$this->assertEquals('Missing mapping for property: \CustomerWithAnExtraProperty->extra', $e->getMessage(), $e->getMessage());
$this->assertEquals('Unexpected property: "extra" in \CustomerWithAnExtraProperty class for "Customer"', $e->getMessage(), $e->getMessage());
}
}

Expand Down

0 comments on commit f5ad64a

Please sign in to comment.