-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented comparison of default values as strings regardless of their PHP types #3355
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ protected function setUp() | |
return; | ||
} | ||
|
||
$this->resetSharedConn(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See build #6465. This is needed since a new functional test is added prior to this one. In this case, the platform instance associated with the shared connection has already initialized the type mappings and won't reinitialize them with the newly added type. |
||
|
||
Type::addType('point', MySqlPointType::class); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morozov not sure that's not my problem but with annotation like this:
it always generates migration becouse of this fix. compared with old version https://3v4l.org/HBLG7 :
result:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not support
true/false
values for boolean type maybe do not allow them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
('0' == false) === true
but('0' === (string) false) === false
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Majkl578 yes yes... but should I update my default value to
0
or this will be fixed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3377
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll loosen
===
back to==
for the patch release, but later, the missing component here seems to beType::convertToDatabaseValue()
. We're loosely comparing a PHP value with a DB value which may have its own not yet discovered edge cases.