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
c8b58d97
Commit
c8b58d97
authored
Sep 10, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/DBAL-423-optimize-non-native-GUID-type-declaration'
Close #465
parents
ecc99eee
83bf4642
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
108 additions
and
2 deletions
+108
-2
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+4
-1
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+3
-1
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+20
-0
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+8
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+10
-0
AbstractPostgreSqlPlatformTestCase.php
...sts/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+8
-0
AbstractSQLServerPlatformTestCase.php
...ests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+8
-0
DB2PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+8
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+8
-0
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+8
-0
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+8
-0
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+15
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
c8b58d97
...
...
@@ -297,7 +297,7 @@ abstract class AbstractPlatform
/**
* Returns the SQL snippet to declare a GUID/UUID field.
*
* By default this maps directly to a
VARCHAR
and only maps to more
* By default this maps directly to a
CHAR(36)
and only maps to more
* special datatypes when the underlying databases support this datatype.
*
* @param array $field
...
...
@@ -306,6 +306,9 @@ abstract class AbstractPlatform
*/
public
function
getGuidTypeDeclarationSQL
(
array
$field
)
{
$field
[
'length'
]
=
36
;
$field
[
'fixed'
]
=
true
;
return
$this
->
getVarcharTypeDeclarationSQL
(
$field
);
}
...
...
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
c8b58d97
...
...
@@ -399,7 +399,9 @@ class Comparator
$changedProperties
[]
=
'default'
;
}
if
(
$properties1
[
'type'
]
instanceof
Types\StringType
||
$properties1
[
'type'
]
instanceof
Types\BinaryType
)
{
if
((
$properties1
[
'type'
]
instanceof
Types\StringType
&&
!
$properties1
[
'type'
]
instanceof
Types\GuidType
)
||
$properties1
[
'type'
]
instanceof
Types\BinaryType
)
{
// check if value of length is set at all, default value assumed otherwise.
$length1
=
$properties1
[
'length'
]
?:
255
;
$length2
=
$properties2
[
'length'
]
?:
255
;
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
c8b58d97
...
...
@@ -259,4 +259,24 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$platform
->
getBlobTypeDeclarationSQL
(
$onlineColumns
[
'col_longblob'
]
->
toArray
())
);
}
/**
* @group DBAL-423
*/
public
function
testDiffListGuidTableColumn
()
{
$offlineTable
=
new
Table
(
'list_guid_table_column'
);
$offlineTable
->
addColumn
(
'col_guid'
,
'guid'
);
$this
->
_sm
->
dropAndCreateTable
(
$offlineTable
);
$onlineTable
=
$this
->
_sm
->
listTableDetails
(
'list_guid_table_column'
);
$comparator
=
new
Comparator
();
$this
->
assertFalse
(
$comparator
->
diffTable
(
$offlineTable
,
$onlineTable
),
"No differences should be detected with the offline vs online schema."
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
c8b58d97
...
...
@@ -596,4 +596,12 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
"CHANGE `select` `select` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 3'"
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
c8b58d97
...
...
@@ -946,4 +946,14 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
_platform
->
quoteStringLiteral
(
$c
)
);
}
/**
* @group DBAL-423
*
* @expectedException \Doctrine\DBAL\DBALException
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
());
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
View file @
c8b58d97
...
...
@@ -664,4 +664,12 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$this
->
_platform
->
getCommentOnColumnSQL
(
'mytable'
,
'id'
,
null
)
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'UUID'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
c8b58d97
...
...
@@ -1101,4 +1101,12 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
),
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'UNIQUEIDENTIFIER'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
View file @
c8b58d97
...
...
@@ -463,4 +463,12 @@ class DB2PlatformTest extends AbstractPlatformTestCase
'RENAME INDEX "schema"."foo" TO "bar"'
,
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
c8b58d97
...
...
@@ -484,4 +484,12 @@ class OraclePlatformTest extends AbstractPlatformTestCase
'ALTER INDEX "schema"."foo" RENAME TO "bar"'
,
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
c8b58d97
...
...
@@ -855,4 +855,12 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
'ALTER INDEX "foo" ON "schema"."table" RENAME TO "bar"'
,
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'UNIQUEIDENTIFIER'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
c8b58d97
...
...
@@ -552,4 +552,12 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
'when used with schemas.'
);
}
/**
* @group DBAL-423
*/
public
function
testReturnsGuidTypeDeclarationSQL
()
{
$this
->
assertSame
(
'CHAR(36)'
,
$this
->
_platform
->
getGuidTypeDeclarationSQL
(
array
()));
}
}
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
c8b58d97
...
...
@@ -1107,4 +1107,19 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$expected
,
$comparator
->
compare
(
$fromSchema
,
$toSchema
));
}
public
function
testCompareGuidColumns
()
{
$comparator
=
new
Comparator
();
$column1
=
new
Column
(
'foo'
,
Type
::
getType
(
'guid'
),
array
(
'comment'
=>
'GUID 1'
));
$column2
=
new
Column
(
'foo'
,
Type
::
getType
(
'guid'
),
array
(
'notnull'
=>
false
,
'length'
=>
'36'
,
'fixed'
=>
true
,
'default'
=>
'NEWID()'
,
'comment'
=>
'GUID 2.'
)
);
$this
->
assertEquals
(
array
(
'notnull'
,
'default'
,
'comment'
),
$comparator
->
diffColumn
(
$column1
,
$column2
));
$this
->
assertEquals
(
array
(
'notnull'
,
'default'
,
'comment'
),
$comparator
->
diffColumn
(
$column2
,
$column1
));
}
}
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