phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.77k stars 1.97k forks source link

allowEmptyStringValues() does not accept custom property/column names #13477

Closed mohahn closed 5 years ago

mohahn commented 6 years ago

I'm using Phalcon 3.4.0 Regarding #440 I'm not happy with the solution of using allowEmptyStringValues() but as it's the only solution it should use custom property names. When using a database table with underscore in column names (i.e. match_type) I'm able to create the following model

class Campaign extends Model {
   protected $matchType;
   public function columnMap() {
      return [ 'match_type' => 'matchType' ];
   }
}

When defining relationships inside initialize() method I'm able to use this camel-case notation for columns, but when using allowEmptyStringValues([ 'matchType' ]) this does not work. I'm still getting validation error, that matchType is required. This empty-string workaround is only working when using real table column names, like allowEmptyStringValues([ 'match_type' ]). So when I'm allowed to use camel-case notation for defining relationships to other models, I should be able to use property names defined by columnMap() in allowEmptyStringValues(), also. Please change this behaviour.

CameronHall commented 5 years ago

@niden I may as well fix this when I do #12975

niden commented 5 years ago

Addressed in https://github.com/phalcon/cphalcon/pull/13692

wurst-hans commented 4 years ago

This is still an issue in Phalcon 4.0.4 allowEmptyStringValues does not recognize columnMap() I have to use real column name instead.

ros-infobest commented 1 year ago

allowEmptyStringValues(), from the name it does allow empty string by excluding column if it is empty but PHPDOcs block made me confuse that it says it skip on update but when field has other than empty value it allows to update.