Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
0d20c853
Unverified
Commit
0d20c853
authored
Sep 27, 2017
by
belgattitude
Committed by
Luís Cobucci
Nov 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more tests for CURRENT_* defaults
parent
f6cb8532
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+14
-5
No files found.
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
0d20c853
...
...
@@ -496,8 +496,14 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
}
/**
* Note: MySQL (as of 5.7.19) does not support default value
* for DATE and TIME fields while MariaDB 10.2+ does
* MariaDB 10.2+ does support CURRENT_TIME and CURRENT_DATE as
* column default values for time and date columns.
* (Not supported on Mysql as of 5.7.19)
*
* Note that MariaDB 10.2+, when storing default in information_schema,
* silently change CURRENT_TIMESTAMP as 'current_timestamp()',
* CURRENT_TIME as 'currtime()' and CURRENT_DATE as 'currdate()'.
* This test also ensure proper aliasing to not trigger a table diff.
*/
public
function
testColumnDefaultValuesCurrentTimeAndDate
()
:
void
{
...
...
@@ -509,23 +515,26 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$table
=
new
Table
(
"test_column_defaults_current_time_and_date"
);
$currentTimestampSql
=
$platform
->
getCurrentTimestampSQL
();
$currentTimeSql
=
$platform
->
getCurrentTimeSQL
();
$currentDateSql
=
$platform
->
getCurrentDateSQL
();
$table
->
addColumn
(
'col_date'
,
'date'
,
[
'notnull'
=>
true
,
'default'
=>
$currentDateSql
]);
$table
->
addColumn
(
'col_time'
,
'time'
,
[
'notnull'
=>
true
,
'default'
=>
$currentTimeSql
]);
$table
->
addColumn
(
'col_datetime'
,
'datetime'
,
[
'default'
=>
$currentTimestampSql
]);
$table
->
addColumn
(
'col_date'
,
'date'
,
[
'default'
=>
$currentDateSql
]);
$table
->
addColumn
(
'col_time'
,
'time'
,
[
'default'
=>
$currentTimeSql
]);
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$onlineTable
=
$this
->
_sm
->
listTableDetails
(
"test_column_defaults_current_time_and_date"
);
self
::
assertSame
(
$currentTimestampSql
,
$onlineTable
->
getColumn
(
'col_datetime'
)
->
getDefault
());
self
::
assertSame
(
$currentDateSql
,
$onlineTable
->
getColumn
(
'col_date'
)
->
getDefault
());
self
::
assertSame
(
$currentTimeSql
,
$onlineTable
->
getColumn
(
'col_time'
)
->
getDefault
());
$comparator
=
new
Comparator
();
$diff
=
$comparator
->
diffTable
(
$table
,
$onlineTable
);
self
::
assertFalse
(
$diff
,
"Tables should be identical with column defau
lts
."
);
self
::
assertFalse
(
$diff
,
"Tables should be identical with column defau
ts time and date
."
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment