getConnection()->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '5.6', '>=')) { $this->markTestSkipped('Default datetime columns are supported since MySQL 5.6.'); } $sql = <<getConnection()->createCommand($sql)->execute(); $schema = $this->getConnection()->getTableSchema('datetime_test'); $dt = $schema->columns['dt']; $this->assertInstanceOf(Expression::className(),$dt->defaultValue); } public function testGetSchemaNames() { $this->markTestSkipped('Schemas are not supported in MySQL.'); } public function constraintsProvider() { $result = parent::constraintsProvider(); $result['1: check'][2] = false; $result['2: primary key'][2]->name = null; $result['2: check'][2] = false; // Work aroung bug in MySQL 5.1 - it creates only this table in lowercase. O_o $result['3: foreign key'][2][0]->foreignTableName = new AnyCaseValue('T_constraints_2'); $result['3: check'][2] = false; $result['4: check'][2] = false; return $result; } /** * When displayed in the INFORMATION_SCHEMA.COLUMNS table, a default CURRENT TIMESTAMP is displayed * as CURRENT_TIMESTAMP up until MariaDB 10.2.2, and as current_timestamp() from MariaDB 10.2.3. * * @see https://mariadb.com/kb/en/library/now/#description * @see https://github.com/yiisoft/yii2/issues/15167 */ public function testAlternativeDisplayOfDefaultCurrentTimestampInMariaDB() { /** * We do not have a real database MariaDB >= 10.2.3 for tests, so we emulate the information that database * returns in response to the query `SHOW FULL COLUMNS FROM ...` */ $schema = new \yii\db\mysql\Schema(); $column = $this->invokeMethod($schema, 'loadColumnSchema', [[ 'field' => 'emulated_MariaDB_field', 'type' => 'timestamp', 'collation' => NULL, 'null' => 'NO', 'key' => '', 'default' => 'current_timestamp()', 'extra' => '', 'privileges' => 'select,insert,update,references', 'comment' => '', ]]); $this->assertInstanceOf(\yii\db\mysql\ColumnSchema::className(), $column); $this->assertInstanceOf(Expression::className(), $column->defaultValue); $this->assertEquals('CURRENT_TIMESTAMP', $column->defaultValue); } }