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
46c95062
Commit
46c95062
authored
Dec 16, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix default values in DB2
parent
daf4f16f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
+21
-15
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+14
-14
DB2SchemaManager.php
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
+7
-1
No files found.
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
46c95062
...
...
@@ -492,7 +492,18 @@ class DB2Platform extends AbstractPlatform
continue
;
}
$queryParts
[]
=
'ADD COLUMN '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$columnDef
=
$column
->
toArray
();
$queryPart
=
'ADD COLUMN '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnDef
);
// Adding non-nullable columns to a table requires a default value to be specified.
if
(
!
empty
(
$columnDef
[
'notnull'
])
&&
!
isset
(
$columnDef
[
'default'
])
&&
empty
(
$columnDef
[
'autoincrement'
])
)
{
$queryPart
.=
' WITH DEFAULT'
;
}
$queryParts
[]
=
$queryPart
;
}
foreach
(
$diff
->
removedColumns
as
$column
)
{
...
...
@@ -544,21 +555,10 @@ class DB2Platform extends AbstractPlatform
*/
public
function
getDefaultValueDeclarationSQL
(
$field
)
{
if
(
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
]
&&
!
isset
(
$field
[
'default'
]))
{
if
(
in_array
((
string
)
$field
[
'type'
],
array
(
"Integer"
,
"BigInteger"
,
"SmallInteger"
)))
{
$field
[
'default'
]
=
0
;
}
else
if
((
string
)
$field
[
'type'
]
==
"DateTime"
)
{
$field
[
'default'
]
=
"00-00-00 00:00:00"
;
}
else
if
((
string
)
$field
[
'type'
]
==
"Date"
)
{
$field
[
'default'
]
=
"00-00-00"
;
}
else
if
((
string
)
$field
[
'type'
]
==
"Time"
)
{
$field
[
'default'
]
=
"00:00:00"
;
}
else
{
$field
[
'default'
]
=
''
;
}
if
(
!
empty
(
$field
[
'autoincrement'
]))
{
return
''
;
}
unset
(
$field
[
'default'
]);
// @todo this needs fixing
if
(
isset
(
$field
[
'version'
])
&&
$field
[
'version'
])
{
if
((
string
)
$field
[
'type'
]
!=
"DateTime"
)
{
$field
[
'default'
]
=
"1"
;
...
...
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
View file @
46c95062
...
...
@@ -60,6 +60,12 @@ class DB2SchemaManager extends AbstractSchemaManager
$scale
=
false
;
$precision
=
false
;
$default
=
null
;
if
(
null
!==
$tableColumn
[
'default'
]
&&
'NULL'
!=
$tableColumn
[
'default'
])
{
$default
=
trim
(
$tableColumn
[
'default'
],
"'"
);
}
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$tableColumn
[
'typename'
]);
switch
(
strtolower
(
$tableColumn
[
'typename'
]))
{
...
...
@@ -86,7 +92,7 @@ class DB2SchemaManager extends AbstractSchemaManager
'length'
=>
$length
,
'unsigned'
=>
(
bool
)
$unsigned
,
'fixed'
=>
(
bool
)
$fixed
,
'default'
=>
(
$tableColumn
[
'default'
]
==
"NULL"
)
?
null
:
$tableColumn
[
'default'
]
,
'default'
=>
$default
,
'notnull'
=>
(
bool
)
(
$tableColumn
[
'nulls'
]
==
'N'
),
'scale'
=>
null
,
'precision'
=>
null
,
...
...
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