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
874bfad2
Unverified
Commit
874bfad2
authored
Nov 19, 2017
by
Luís Cobucci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve readability of AbstractPlatform#getDefaultValueDeclarationSQL()
parent
54a83488
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
20 deletions
+31
-20
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+31
-20
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
874bfad2
...
...
@@ -2274,28 +2274,39 @@ abstract class AbstractPlatform
*/
public
function
getDefaultValueDeclarationSQL
(
$field
)
{
$default
=
empty
(
$field
[
'notnull'
])
?
' DEFAULT NULL'
:
''
;
if
(
isset
(
$field
[
'default'
]))
{
$default
=
" DEFAULT '"
.
$field
[
'default'
]
.
"'"
;
if
(
isset
(
$field
[
'type'
]))
{
$type
=
(
string
)
$field
[
'type'
];
if
(
in_array
(
$type
,
[
"Integer"
,
"BigInt"
,
"SmallInt"
],
true
))
{
$default
=
" DEFAULT "
.
$field
[
'default'
];
}
elseif
(
in_array
(
$type
,
[
'DateTime'
,
'DateTimeTz'
,
'DateTimeImmutable'
,
'DateTimeTzImmutable'
],
true
)
&&
$field
[
'default'
]
===
$this
->
getCurrentTimestampSQL
())
{
$default
=
" DEFAULT "
.
$this
->
getCurrentTimestampSQL
();
}
elseif
(
in_array
(
$type
,
[
'Time'
,
'TimeImmutable'
],
true
)
&&
$field
[
'default'
]
===
$this
->
getCurrentTimeSQL
())
{
$default
=
" DEFAULT "
.
$this
->
getCurrentTimeSQL
();
}
elseif
(
in_array
(
$type
,
[
'Date'
,
'DateImmutable'
],
true
)
&&
$field
[
'default'
]
===
$this
->
getCurrentDateSQL
())
{
$default
=
" DEFAULT "
.
$this
->
getCurrentDateSQL
();
}
elseif
(
$type
===
'Boolean'
)
{
$default
=
" DEFAULT '"
.
$this
->
convertBooleans
(
$field
[
'default'
])
.
"'"
;
}
}
if
(
!
isset
(
$field
[
'default'
]))
{
return
empty
(
$field
[
'notnull'
])
?
' DEFAULT NULL'
:
''
;
}
$default
=
$field
[
'default'
];
if
(
!
isset
(
$field
[
'type'
]))
{
return
" DEFAULT '"
.
$default
.
"'"
;
}
$type
=
(
string
)
$field
[
'type'
];
if
(
in_array
(
$type
,
[
"Integer"
,
"BigInt"
,
"SmallInt"
],
true
))
{
return
" DEFAULT "
.
$default
;
}
if
(
in_array
(
$type
,
[
'DateTime'
,
'DateTimeTz'
,
'DateTimeImmutable'
,
'DateTimeTzImmutable'
],
true
)
&&
$default
===
$this
->
getCurrentTimestampSQL
())
{
return
" DEFAULT "
.
$this
->
getCurrentTimestampSQL
();
}
if
(
in_array
(
$type
,
[
'Time'
,
'TimeImmutable'
],
true
)
&&
$default
===
$this
->
getCurrentTimeSQL
())
{
return
" DEFAULT "
.
$this
->
getCurrentTimeSQL
();
}
if
(
in_array
(
$type
,
[
'Date'
,
'DateImmutable'
],
true
)
&&
$default
===
$this
->
getCurrentDateSQL
())
{
return
" DEFAULT "
.
$this
->
getCurrentDateSQL
();
}
if
(
$type
===
'Boolean'
)
{
return
" DEFAULT '"
.
$this
->
convertBooleans
(
$default
)
.
"'"
;
}
return
$default
;
return
" DEFAULT '"
.
$default
.
"'"
;
}
/**
...
...
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