Skip to content

Commit

Permalink
Make sure that the primary key is stored in lowercase
Browse files Browse the repository at this point in the history
Often, developers set the column names in different cases for the $primary_key static field in the Model. However, the object for the Model stores column names as lowercase (in $attributes). This causes confusion at times (for example, when checking if "$attributes[$pk]" is set while inserting a new record).

This small bit of code makes sure no matter what case the developer sets his primary key ("myPrimaryKey" or "myprimaryKey"), the key will always be stored in all lowercase ("myprimarykey").
  • Loading branch information
kamrandotpk authored and koenpunt committed Dec 6, 2014
1 parent 06932a9 commit b84bc4d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ private function set_primary_key()
$this->pk[] = $c->inflected_name;
}
}
// make sure the primary key is stored in lowercase
$this->pk = array_map('strtolower', $this->pk);
}

private function set_table_name()
Expand Down

0 comments on commit b84bc4d

Please sign in to comment.