Skip to content
Permalink
Browse files

Improving the error message for associations with no PK.

This makes it more clear what needs to be done to fix the issue.
  • Loading branch information...
burzum committed Jun 13, 2016
1 parent 376fc96 commit 74e396809512538780acd4cc819c6af8386a183c
Showing with 10 additions and 0 deletions.
  1. +5 −0 src/ORM/Association.php
  2. +5 −0 src/ORM/Association/BelongsTo.php
@@ -841,6 +841,11 @@ protected function _joinCondition($options)
$bindingKey = (array)$this->bindingKey();
if (count($foreignKey) !== count($bindingKey)) {
if (empty($bindingKey)) {
$msg = 'The "%s" table does not define a primary key. Please set one.';
throw new RuntimeException(sprintf($msg, $this->target()->table()));
}
$msg = 'Cannot match provided foreignKey for "%s", got "(%s)" but expected foreign key for "(%s)"';
throw new RuntimeException(sprintf(
$msg,
@@ -157,6 +157,11 @@ protected function _joinCondition($options)
$bindingKey = (array)$this->bindingKey();
if (count($foreignKey) !== count($bindingKey)) {
if (empty($bindingKey)) {
$msg = 'The "%s" table does not define a primary key. Please set one.';
throw new RuntimeException(sprintf($msg, $this->target()->table()));
}
$msg = 'Cannot match provided foreignKey for "%s", got "(%s)" but expected foreign key for "(%s)"';
throw new RuntimeException(sprintf(
$msg,

0 comments on commit 74e3968

Please sign in to comment.
You can’t perform that action at this time.