Fix for empty primary keys in create method #45

wants to merge 1 commit into


None yet

3 participants


The create method will check if the primary key is set, but will not check whether it is empty. The ORM should not allow empty primary keys. I have added a check against empty primary key.

@kemo kemo commented on the diff Apr 10, 2014
@@ -1221,7 +1221,7 @@ public function create(Validation $validation = NULL)
- if ( ! array_key_exists($this->_primary_key, $data))
+ if ( ! array_key_exists($this->_primary_key, $data) && ! empty($data[$this->_primary_key]) )
kemo Apr 10, 2014

Use AND instead of &&

kemo Apr 10, 2014

This condition will never be true?

Kohana PHP Framework member

Closing as the "adjusted" condition in this pull request will never be true as far as I can tell. Let me know if you think otherwise and I will reopen this.

@kemo kemo closed this Apr 10, 2014
@hkdobrev hkdobrev deleted the unknown repository branch May 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment