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
7386b2cc
Commit
7386b2cc
authored
Aug 19, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/#662-datetime-tz-default-value-support'
Close #662
parents
c1c33531
7a33aa26
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+2
-2
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+1
-1
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+26
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
7386b2cc
...
...
@@ -2239,9 +2239,9 @@ abstract class AbstractPlatform
if
(
isset
(
$field
[
'default'
]))
{
$default
=
" DEFAULT '"
.
$field
[
'default'
]
.
"'"
;
if
(
isset
(
$field
[
'type'
]))
{
if
(
in_array
((
string
)
$field
[
'type'
],
array
(
"Integer"
,
"BigInteger"
,
"SmallInteger"
)))
{
if
(
in_array
((
string
)
$field
[
'type'
],
array
(
"Integer"
,
"BigInteger"
,
"SmallInteger"
)))
{
$default
=
" DEFAULT "
.
$field
[
'default'
];
}
elseif
(
(
string
)
$field
[
'type'
]
==
'DateTime'
&&
$field
[
'default'
]
==
$this
->
getCurrentTimestampSQL
())
{
}
elseif
(
in_array
((
string
)
$field
[
'type'
],
array
(
'DateTime'
,
'DateTimeTz'
))
&&
$field
[
'default'
]
==
$this
->
getCurrentTimestampSQL
())
{
$default
=
" DEFAULT "
.
$this
->
getCurrentTimestampSQL
();
}
elseif
((
string
)
$field
[
'type'
]
==
'Time'
&&
$field
[
'default'
]
==
$this
->
getCurrentTimeSQL
())
{
$default
=
" DEFAULT "
.
$this
->
getCurrentTimeSQL
();
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
7386b2cc
...
...
@@ -1458,7 +1458,7 @@ class SQLServerPlatform extends AbstractPlatform
return
" DEFAULT "
.
$field
[
'default'
];
}
if
(
(
string
)
$field
[
'type'
]
==
'DateTime'
&&
$field
[
'default'
]
==
$this
->
getCurrentTimestampSQL
())
{
if
(
in_array
((
string
)
$field
[
'type'
],
array
(
'DateTime'
,
'DateTimeTz'
))
&&
$field
[
'default'
]
==
$this
->
getCurrentTimestampSQL
())
{
return
" DEFAULT "
.
$this
->
getCurrentTimestampSQL
();
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
7386b2cc
...
...
@@ -440,6 +440,32 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
markTestSkipped
(
'Platform does not support Column comments.'
);
}
public
function
testGetDefaultValueDeclarationSQL
()
{
// non-timestamp value will get single quotes
$field
=
array
(
'type'
=>
'string'
,
'default'
=>
'non_timestamp'
);
$this
->
assertEquals
(
" DEFAULT 'non_timestamp'"
,
$this
->
_platform
->
getDefaultValueDeclarationSQL
(
$field
));
}
public
function
testGetDefaultValueDeclarationSQLDateTime
()
{
// timestamps on datetime types should not be quoted
foreach
(
array
(
'datetime'
,
'datetimetz'
)
as
$type
)
{
$field
=
array
(
'type'
=>
Type
::
getType
(
$type
),
'default'
=>
$this
->
_platform
->
getCurrentTimestampSQL
()
);
$this
->
assertEquals
(
' DEFAULT '
.
$this
->
_platform
->
getCurrentTimestampSQL
(),
$this
->
_platform
->
getDefaultValueDeclarationSQL
(
$field
));
}
}
/**
* @group DBAL-45
*/
...
...
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