#5659: [TEST][PATCH]Model::deconstruct() incorrectly handles empty `time` fields
---------------------------------------+------------------------------------
    Reporter:  BrendonKoz              |          Type:  Bug   
      Status:  new                     |      Priority:  Medium
   Milestone:  1.2.x.x                 |     Component:  Model 
     Version:  RC3                     |      Severity:  Major 
    Keywords:  model test deconstruct  |   Php_version:  n/a   
Cake_version:                          |  
---------------------------------------+------------------------------------
 With a clean bake (MVC) of a database table containing a field of type
 `time`, taking the view files (add and edit) and modifying the FormHelper
 to allow that specific field, set in the database to allow null, the
 ability to be empty (''example below'')...
 {{{
 $form->input('timefield', array('empty'=>true));
 }}}
 ...when the field is submitted as empty, it is saved in the database as
 '00:00:00'.  When attempting to further edit the field and reset it as
 empty, it will continually save as '00:00:00', not an expected occurrence
 (for me).

 Tracking the issue back, it seems that Model::deconstruct(), called from
 Model::save(), will convert an empty array of data (containing 'hour',
 'minute', and 'second' for index values) to the aforementioned string.
 Similarly valued `timestamp`, `datetime`, and `date` type fields (also
 allowed as null) will be returned as a null or empty value, and then saved
 as such to the database.

 I would have expected a value of NULL be allowed for a field of type
 `time`.  If my expectations are correct, I have attached a DIFF file.

 My DIFF is of the model.test.php and model.php files.  The model.test.php
 (assuming this is not expected behavior) should probably be worked in to
 test for null return values of all currently tested SQL datatypes.  My
 suggested patch for model.php may be scrutinized; it worked but may not be
 optimal.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5659>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to