You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create table messages
(
id int auto_increment
primary key,
data longtext null comment 'Request data must be valid XML',
MsgId varchar(35) null comment 'Message identifier',
updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP,
created_at timestamp(5) default CURRENT_TIMESTAMP(5) not null,
constraint MsgId
unique (MsgId)
)
charset=utf8
;
Created Fixture to write test:
use Cake\TestSuite\Fixture\TestFixture;
/**
* MessagesFixture
*
*/
class MessagesFixture extends TestFixture
{
public $import = ['model' => 'Messages'];
/**
* Records
*
* @var array
*/
public $records = [];
}
Wrote test:
class MessagesTableTest extends TestCase
{
public $fixtures = [
'messages'
];
public function testInitialize()
{
$this->markTestIncomplete('Not implemented yet.');
}
}
What happened
After starting this test I've got an error:
Warning Error: Fixture creation for "messages" failed "SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'" in [/var/www/html/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php, line 313]
This table did not created for my test ad generates invalid DDL command for it(retrived with xdebug):
CREATE TABLE `messages` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`data` LONGTEXT COLLATE utf8_general_ci COMMENT 'Request data must be valid XML',
`MsgId` VARCHAR(35) COLLATE utf8_general_ci COMMENT 'Message identifier',
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_at` TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP(5)',
PRIMARY KEY (`id`),
UNIQUE KEY `MsgId` (`MsgId`)
) ENGINE=InnoDB
Error in scheme is here:
`created_at` TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP(5)',
Must be
`created_at` TIMESTAMP(5) NOT NULL DEFAULT 'CURRENT_TIMESTAMP(5)',
What you expected to happen
Create table for tests with valid scheme
The text was updated successfully, but these errors were encountered:
We don't currently support preserving the fractional microseconds in TIMESTAMP columns for schema generation. We could trim off the (5) from CURRENT_TIMESTAMP to prevent this issue though.
This is a (multiple allowed):
bug
enhancement
feature-discussion (RFC)
CakePHP Version: 3.6.12.
Mysql Version: 5.6.39.
What you did
Created table with scheme
Created Fixture to write test:
Wrote test:
What happened
After starting this test I've got an error:
This table did not created for my test ad generates invalid DDL command for it(retrived with xdebug):
Error in scheme is here:
Must be
What you expected to happen
Create table for tests with valid scheme
The text was updated successfully, but these errors were encountered: