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
9d09d2b1
Commit
9d09d2b1
authored
Sep 09, 2016
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/#2277-#2182-DBAL-939-fix-reverse-engineering-boolean-on-db2-2.5' into 2.5
Close #2182 Close #2277 Close DBAL-939
parents
0045a7ac
4b20cd73
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
127 additions
and
1 deletion
+127
-1
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+24
-0
DB2SchemaManager.php
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
+8
-0
Db2SchemaManagerTest.php
...ine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
+19
-1
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+41
-0
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+8
-0
DB2PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+19
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+8
-0
No files found.
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
9d09d2b1
...
...
@@ -26,6 +26,7 @@ use Doctrine\DBAL\Schema\Identifier;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\Types\Type
;
class
DB2Platform
extends
AbstractPlatform
{
...
...
@@ -78,6 +79,20 @@ class DB2Platform extends AbstractPlatform
);
}
/**
* {@inheritdoc}
*/
public
function
isCommentedDoctrineType
(
Type
$doctrineType
)
{
if
(
$doctrineType
->
getName
()
===
Type
::
BOOLEAN
)
{
// We require a commented boolean type in order to distinguish between boolean and smallint
// as both (have to) map to the same native type.
return
true
;
}
return
parent
::
isCommentedDoctrineType
(
$doctrineType
);
}
/**
* {@inheritDoc}
*/
...
...
@@ -272,6 +287,7 @@ class DB2Platform extends AbstractPlatform
c.scale,
c.identity,
tc.type AS tabconsttype,
c.remarks AS comment,
k.colseq,
CASE
WHEN c.generated = 'D' THEN 1
...
...
@@ -418,6 +434,14 @@ class DB2Platform extends AbstractPlatform
return
false
;
}
/**
* {@inheritdoc}
*/
public
function
supportsCommentOnStatement
()
{
return
true
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
View file @
9d09d2b1
...
...
@@ -65,6 +65,11 @@ class DB2SchemaManager extends AbstractSchemaManager
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$tableColumn
[
'typename'
]);
if
(
isset
(
$tableColumn
[
'comment'
]))
{
$type
=
$this
->
extractDoctrineTypeFromComment
(
$tableColumn
[
'comment'
],
$type
);
$tableColumn
[
'comment'
]
=
$this
->
removeDoctrineTypeFromComment
(
$tableColumn
[
'comment'
],
$type
);
}
switch
(
strtolower
(
$tableColumn
[
'typename'
]))
{
case
'varchar'
:
$length
=
$tableColumn
[
'length'
];
...
...
@@ -94,6 +99,9 @@ class DB2SchemaManager extends AbstractSchemaManager
'notnull'
=>
(
bool
)
(
$tableColumn
[
'nulls'
]
==
'N'
),
'scale'
=>
null
,
'precision'
=>
null
,
'comment'
=>
isset
(
$tableColumn
[
'comment'
])
&&
$tableColumn
[
'comment'
]
!==
''
?
$tableColumn
[
'comment'
]
:
null
,
'platformOptions'
=>
array
(),
);
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
View file @
9d09d2b1
...
...
@@ -2,9 +2,27 @@
namespace
Doctrine\Tests\DBAL\Functional\Schema
;
require_once
__DIR__
.
'/../../../TestInit.php'
;
use
Doctrine\DBAL\Schema\Table
;
class
Db2SchemaManagerTest
extends
SchemaManagerFunctionalTestCase
{
/**
* @group DBAL-939
*/
public
function
testGetBooleanColumn
()
{
$table
=
new
Table
(
'boolean_column_test'
);
$table
->
addColumn
(
'bool'
,
'boolean'
);
$table
->
addColumn
(
'bool_commented'
,
'boolean'
,
array
(
'comment'
=>
"That's a comment"
));
$this
->
_sm
->
createTable
(
$table
);
$columns
=
$this
->
_sm
->
listTableColumns
(
'boolean_column_test'
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Types\BooleanType'
,
$columns
[
'bool'
]
->
getType
());
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Types\BooleanType'
,
$columns
[
'bool_commented'
]
->
getType
());
$this
->
assertNull
(
$columns
[
'bool'
]
->
getComment
());
$this
->
assertSame
(
"That's a comment"
,
$columns
[
'bool_commented'
]
->
getComment
());
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
9d09d2b1
...
...
@@ -107,6 +107,34 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
_platform
->
registerDoctrineTypeMapping
(
'foo'
,
'bar'
);
}
/**
* @group DBAL-939
*
* @dataProvider getIsCommentedDoctrineType
*/
public
function
testIsCommentedDoctrineType
(
Type
$type
,
$commented
)
{
$this
->
assertSame
(
$commented
,
$this
->
_platform
->
isCommentedDoctrineType
(
$type
));
}
public
function
getIsCommentedDoctrineType
()
{
$this
->
setUp
();
$data
=
array
();
foreach
(
Type
::
getTypesMap
()
as
$typeName
=>
$className
)
{
$type
=
Type
::
getType
(
$typeName
);
$data
[
$typeName
]
=
array
(
$type
,
$type
->
requiresSQLCommentHint
(
$this
->
_platform
),
);
}
return
$data
;
}
public
function
testCreateWithNoColumns
()
{
$table
=
new
Table
(
'test'
);
...
...
@@ -667,6 +695,19 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
return
true
;
}
public
function
testSupportsCommentOnStatement
()
{
$this
->
assertSame
(
$this
->
supportsCommentOnStatement
(),
$this
->
_platform
->
supportsCommentOnStatement
());
}
/**
* @return bool
*/
protected
function
supportsCommentOnStatement
()
{
return
false
;
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
9d09d2b1
...
...
@@ -227,6 +227,14 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$this
->
assertTrue
(
$this
->
_platform
->
supportsSequences
());
}
/**
* {@inheritdoc}
*/
protected
function
supportsCommentOnStatement
()
{
return
true
;
}
public
function
testModifyLimitQuery
()
{
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
,
0
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
View file @
9d09d2b1
...
...
@@ -115,6 +115,7 @@ class DB2PlatformTest extends AbstractPlatformTestCase
{
return
array
(
"CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))"
,
"COMMENT ON COLUMN test.id IS 'This is a comment'"
,
);
}
...
...
@@ -134,6 +135,7 @@ class DB2PlatformTest extends AbstractPlatformTestCase
{
return
array
(
'CREATE TABLE test (id INTEGER NOT NULL, "data" CLOB(1M) NOT NULL, PRIMARY KEY(id))'
,
'COMMENT ON COLUMN test."data" IS \'(DC2Type:array)\''
,
);
}
...
...
@@ -285,6 +287,15 @@ class DB2PlatformTest extends AbstractPlatformTestCase
$this
->
assertSame
(
'datetime'
,
$this
->
_platform
->
getDoctrineTypeMapping
(
'timestamp'
));
}
public
function
getIsCommentedDoctrineType
()
{
$data
=
parent
::
getIsCommentedDoctrineType
();
$data
[
Type
::
BOOLEAN
]
=
array
(
Type
::
getType
(
Type
::
BOOLEAN
),
true
);
return
$data
;
}
public
function
testGeneratesDDLSnippets
()
{
$this
->
assertEquals
(
"CREATE DATABASE foobar"
,
$this
->
_platform
->
getCreateDatabaseSQL
(
'foobar'
));
...
...
@@ -656,6 +667,14 @@ class DB2PlatformTest extends AbstractPlatformTestCase
return
false
;
}
/**
* {@inheritdoc}
*/
protected
function
supportsCommentOnStatement
()
{
return
true
;
}
/**
* {@inheritdoc}
*/
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
9d09d2b1
...
...
@@ -189,6 +189,14 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$this
->
assertTrue
(
$this
->
_platform
->
supportsSavepoints
());
}
/**
* {@inheritdoc}
*/
protected
function
supportsCommentOnStatement
()
{
return
true
;
}
public
function
getGenerateIndexSql
()
{
return
'CREATE INDEX my_idx ON mytable (user_name, last_login)'
;
...
...
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