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
4389a258
Unverified
Commit
4389a258
authored
Nov 23, 2018
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented comparison of default values as strings regardless of their PHP types
Fixes #3336.
parent
296b0e51
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
6 deletions
+45
-6
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+4
-6
ComparatorTest.php
.../Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php
+39
-0
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+2
-0
No files found.
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
4389a258
...
@@ -432,12 +432,10 @@ class Comparator
...
@@ -432,12 +432,10 @@ class Comparator
$changedProperties
[]
=
'comment'
;
$changedProperties
[]
=
'comment'
;
}
}
if
(
$properties1
[
'default'
]
!==
$properties2
[
'default'
]
||
// Null values need to be checked additionally as they tell whether to create or drop a default value.
// Null values need to be checked additionally as they tell whether to create or drop a default value.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
if
((
$properties1
[
'default'
]
===
null
)
!==
(
$properties2
[
'default'
]
===
null
)
(
$properties1
[
'default'
]
===
null
&&
$properties2
[
'default'
]
!==
null
)
||
||
(
string
)
$properties1
[
'default'
]
!==
(
string
)
$properties2
[
'default'
])
{
(
$properties2
[
'default'
]
===
null
&&
$properties1
[
'default'
]
!==
null
)
)
{
$changedProperties
[]
=
'default'
;
$changedProperties
[]
=
'default'
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php
0 → 100644
View file @
4389a258
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\Tests\DBAL\Functional\Schema
;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
class
ComparatorTest
extends
DbalFunctionalTestCase
{
/** @var AbstractSchemaManager */
private
$schemaManager
;
/** @var Comparator */
private
$comparator
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
schemaManager
=
$this
->
connection
->
getSchemaManager
();
$this
->
comparator
=
new
Comparator
();
}
public
function
testDefaultValueComparison
()
{
$table
=
new
Table
(
'default_value'
);
$table
->
addColumn
(
'id'
,
'integer'
,
[
'default'
=>
1
]);
$this
->
schemaManager
->
createTable
(
$table
);
$onlineTable
=
$this
->
schemaManager
->
listTableDetails
(
'default_value'
);
self
::
assertFalse
(
$this
->
comparator
->
diffTable
(
$table
,
$onlineTable
));
}
}
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
4389a258
...
@@ -23,6 +23,8 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...
@@ -23,6 +23,8 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
return
;
return
;
}
}
$this
->
resetSharedConn
();
Type
::
addType
(
'point'
,
MySqlPointType
::
class
);
Type
::
addType
(
'point'
,
MySqlPointType
::
class
);
}
}
...
...
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