-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#13297] - Added size to datetime/time and timestamp fields
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,14 @@ | |
|
||
use Codeception\Example; | ||
use IntegrationTester; | ||
use Phalcon\Db\Column; | ||
use Phalcon\Db\Dialect\Mysql; | ||
use Phalcon\Test\Fixtures\Traits\DialectTrait; | ||
use Phalcon\Test\Fixtures\Traits\DiTrait; | ||
|
||
class AddColumnCest | ||
{ | ||
use DiTrait; | ||
use DialectTrait; | ||
|
||
/** | ||
|
@@ -44,6 +47,54 @@ public function testAddColumn(IntegrationTester $I, Example $example) | |
$I->assertEquals($expected, $actual); | ||
} | ||
|
||
/** | ||
* Tests Dialect::addColumn | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-12-23 | ||
*/ | ||
public function dbDialectAddColumnDateFractal(IntegrationTester $I) | ||
{ | ||
$dialect = new Mysql(); | ||
|
||
$options = [ | ||
"type" => Column::TYPE_DATETIME, | ||
"notNull" => false, | ||
"size" => 2, | ||
]; | ||
$column = new Column('ftest', $options); | ||
$actual = $dialect->addColumn('fractal_dates', "", $column); | ||
$I->assertEquals( | ||
"ALTER TABLE `fractal_dates` ADD `ftest` DATETIME(2)", | ||
$actual | ||
); | ||
|
||
$options = [ | ||
"type" => Column::TYPE_TIME, | ||
"notNull" => false, | ||
"size" => 2, | ||
]; | ||
$column = new Column('ftest', $options); | ||
$actual = $dialect->addColumn('fractal_dates', "", $column); | ||
$I->assertEquals( | ||
"ALTER TABLE `fractal_dates` ADD `ftest` TIME(2)", | ||
$actual | ||
); | ||
|
||
$options = [ | ||
"type" => Column::TYPE_TIMESTAMP, | ||
"notNull" => false, | ||
"size" => 2, | ||
]; | ||
$column = new Column('ftest', $options); | ||
$actual = $dialect->addColumn('fractal_dates', "", $column); | ||
$I->assertEquals( | ||
"ALTER TABLE `fractal_dates` ADD `ftest` TIMESTAMP(2)", | ||
$actual | ||
); | ||
} | ||
|
||
|
||
protected function getAddColumnFixtures(): array | ||
{ | ||
return [ | ||
|