#6205: Invalid default value for datetime/timestamp
---------------------------+------------------------------------------------
    Reporter:  verbal      |          Type:  Bug   
      Status:  new         |      Priority:  Medium
   Milestone:  1.2.x.x     |     Component:  MySQLi
     Version:  1.2 Final   |      Severity:  Normal
    Keywords:              |   Php_version:  PHP 5 
Cake_version:  1.2.1.8004  |  
---------------------------+------------------------------------------------
 When testing my app I got SQL error "1067: Invalid default value for
 'created'".

 My fixture:

 {{{
 class UserFixture extends CakeTestFixture {
     var $name = 'User';
     var $import = array('model' => 'User', 'records' => true);

 }
 }}}

 Create statement that gives error looks like this:

 {{{
 CREATE TABLE `users` (
 `id` int(10) NOT NULL AUTO_INCREMENT,
 `name` varchar(255) DEFAULT '' NOT NULL,
 `password` varchar(255) DEFAULT '' NOT NULL,
 `created` datetime DEFAULT '' NOT NULL,
 `modified` datetime DEFAULT '' NOT NULL,
 PRIMARY KEY  (`id`));
 }}}

 Looking into the cake code I've noticed that you have following lines
 (dbo_source.php, function buildColumn):

 {{{
 if (($column['type'] == 'integer' || $column['type'] == 'float' ) &&
 isset($column['default']) && $column['default'] === '') {
     $column['default'] = null;
 }
 }}}

 so I've copied it and changed it accordingly for datetime and timestamp as
 both gave the same error:

 {{{
 if (($column['type'] == 'datetime' || $column['type'] == 'timestamp' ) &&
 isset($column['default']) && $column['default'] === '') {
     $column['default'] = null;
 }
 }}}

 I'm using mysql 5.0.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/6205>
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 tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to