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
0782e925
Commit
0782e925
authored
Dec 27, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix altering column from notnull to null in Oracle
parent
2196da9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
6 deletions
+68
-6
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+26
-1
OracleSchemaManagerTest.php
.../Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
+31
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+11
-5
No files found.
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
0782e925
...
@@ -686,7 +686,7 @@ LEFT JOIN user_cons_columns r_cols
...
@@ -686,7 +686,7 @@ LEFT JOIN user_cons_columns r_cols
$columnInfo
[
'notnull'
]
=
false
;
$columnInfo
[
'notnull'
]
=
false
;
}
}
$fields
[]
=
$column
->
getQuotedName
(
$this
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
''
,
$columnInfo
);
$fields
[]
=
$column
->
getQuotedName
(
$this
)
.
$this
->
getColumnDeclarationSQL
(
''
,
$columnInfo
);
}
}
if
(
$columnHasChangedComment
)
{
if
(
$columnHasChangedComment
)
{
...
@@ -736,6 +736,31 @@ LEFT JOIN user_cons_columns r_cols
...
@@ -736,6 +736,31 @@ LEFT JOIN user_cons_columns r_cols
return
array_merge
(
$sql
,
$tableSql
,
$columnSql
);
return
array_merge
(
$sql
,
$tableSql
,
$columnSql
);
}
}
/**
* {@inheritdoc}
*/
public
function
getColumnDeclarationSQL
(
$name
,
array
$field
)
{
if
(
isset
(
$field
[
'columnDefinition'
]))
{
$columnDef
=
$this
->
getCustomTypeDeclarationSQL
(
$field
);
}
else
{
$default
=
$this
->
getDefaultValueDeclarationSQL
(
$field
);
$notnull
=
empty
(
$field
[
'notnull'
])
?
' NULL'
:
' NOT NULL'
;
$unique
=
(
isset
(
$field
[
'unique'
])
&&
$field
[
'unique'
])
?
' '
.
$this
->
getUniqueFieldDeclarationSQL
()
:
''
;
$check
=
(
isset
(
$field
[
'check'
])
&&
$field
[
'check'
])
?
' '
.
$field
[
'check'
]
:
''
;
$typeDecl
=
$field
[
'type'
]
->
getSqlDeclaration
(
$field
,
$this
);
$columnDef
=
$typeDecl
.
$default
.
$notnull
.
$unique
.
$check
;
}
return
$name
.
' '
.
$columnDef
;
}
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
View file @
0782e925
...
@@ -57,4 +57,35 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
...
@@ -57,4 +57,35 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Types\BinaryType'
,
$table
->
getColumn
(
'column_binary'
)
->
getType
());
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Types\BinaryType'
,
$table
->
getColumn
(
'column_binary'
)
->
getType
());
$this
->
assertFalse
(
$table
->
getColumn
(
'column_binary'
)
->
getFixed
());
$this
->
assertFalse
(
$table
->
getColumn
(
'column_binary'
)
->
getFixed
());
}
}
/**
* @group DBAL-472
*/
public
function
testAlterTableColumnNotNull
()
{
$comparator
=
new
Schema\Comparator
();
$tableName
=
'list_table_column_notnull'
;
$table
=
new
Schema\Table
(
$tableName
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addColumn
(
'foo'
,
'integer'
);
$table
->
setPrimaryKey
(
array
(
'id'
));
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$columns
=
$this
->
_sm
->
listTableColumns
(
$tableName
);
$this
->
assertTrue
(
$columns
[
'id'
]
->
getNotnull
());
$this
->
assertTrue
(
$columns
[
'foo'
]
->
getNotnull
());
$diffTable
=
clone
$table
;
$diffTable
->
changeColumn
(
'foo'
,
array
(
'notnull'
=>
false
));
$this
->
_sm
->
alterTable
(
$comparator
->
diffTable
(
$table
,
$diffTable
));
$columns
=
$this
->
_sm
->
listTableColumns
(
$tableName
);
$this
->
assertTrue
(
$columns
[
'id'
]
->
getNotnull
());
$this
->
assertFalse
(
$columns
[
'foo'
]
->
getNotnull
());
}
}
}
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
0782e925
...
@@ -63,13 +63,13 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -63,13 +63,13 @@ class OraclePlatformTest extends AbstractPlatformTestCase
public
function
getGenerateTableSql
()
public
function
getGenerateTableSql
()
{
{
return
'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL, PRIMARY KEY(id))'
;
return
'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL
NULL
, PRIMARY KEY(id))'
;
}
}
public
function
getGenerateTableWithMultiColumnUniqueIndexSql
()
public
function
getGenerateTableWithMultiColumnUniqueIndexSql
()
{
{
return
array
(
return
array
(
'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL
, bar VARCHAR2(255) DEFAULT
NULL)'
,
'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL
NULL, bar VARCHAR2(255) DEFAULT NULL
NULL)'
,
'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)'
,
'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)'
,
);
);
}
}
...
@@ -77,8 +77,8 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -77,8 +77,8 @@ class OraclePlatformTest extends AbstractPlatformTestCase
public
function
getGenerateAlterTableSql
()
public
function
getGenerateAlterTableSql
()
{
{
return
array
(
return
array
(
'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL)'
,
'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL
NULL
)'
,
"ALTER TABLE mytable MODIFY (baz
VARCHAR2(255) DEFAULT 'def' NOT NULL, bloo
NUMBER(1) DEFAULT '0' NOT NULL)"
,
"ALTER TABLE mytable MODIFY (baz
VARCHAR2(255) DEFAULT 'def' NOT NULL, bloo
NUMBER(1) DEFAULT '0' NOT NULL)"
,
"ALTER TABLE mytable DROP (foo)"
,
"ALTER TABLE mytable DROP (foo)"
,
"ALTER TABLE mytable RENAME TO userlist"
,
"ALTER TABLE mytable RENAME TO userlist"
,
);
);
...
@@ -326,9 +326,15 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -326,9 +326,15 @@ class OraclePlatformTest extends AbstractPlatformTestCase
),
),
array
(
'type'
,
'notnull'
)
array
(
'type'
,
'notnull'
)
);
);
$tableDiff
->
changedColumns
[
'metar'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'metar'
,
new
\Doctrine\DBAL\Schema\Column
(
'metar'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'string'
),
array
(
'length'
=>
2000
,
'notnull'
=>
false
)
),
array
(
'notnull'
)
);
$expectedSql
=
array
(
$expectedSql
=
array
(
"ALTER TABLE mytable MODIFY (foo
VARCHAR2(255) DEFAULT 'bla', baz VARCHAR2(255) DEFAULT 'bla' NOT
NULL)"
,
"ALTER TABLE mytable MODIFY (foo
VARCHAR2(255) DEFAULT 'bla' NULL, baz VARCHAR2(255) DEFAULT 'bla' NOT NULL, metar VARCHAR2(2000) DEFAULT NULL
NULL)"
,
);
);
$this
->
assertEquals
(
$expectedSql
,
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
));
$this
->
assertEquals
(
$expectedSql
,
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
));
}
}
...
...
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