Do not use quotes to represent a boolean default#5108
Merged
morozov merged 1 commit intodoctrine:3.3.xfrom Dec 12, 2021
Merged
Conversation
greg0ire
approved these changes
Dec 12, 2021
SenseException
approved these changes
Dec 12, 2021
Member
Author
I checked that the following test passes with dbal/tests/Functional/Schema/PostgreSQLSchemaManagerTest.php Lines 300 to 304 in 0edd213 We can update the test separately so it doesn't block merging the patch. |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Representing boolean default as a string literal may cause false-positive diffs during platform-aware schema comparison if the platform doesn't support boolean columns natively (IBM DB2, Oracle, MySQL) and doesn't implement any hacks for introspection of boolean columns:
dbal/src/Platforms/AbstractMySQLPlatform.php
Line 1052 in 2b3504f
dbal/src/Platforms/OraclePlatform.php
Line 1148 in 2b3504f
See #5107 (comment) for more details.
The existing assertions that expect SQL like
TINYINT(1) DEFAULT '0'are obviously wrong and were likely implemented by copy/pasting the actual value as expected.According to the functional tests, there are no cases where a boolean default would have to be represented as a string literal. All supported platforms use integer
0and1to represent boolean values. PostgreSQL supports booleans literalstrue/false.Note that the documentation for PostgreSQL 9.3 is the last version that mentions the support for quoted
'true'and'false'as valid boolean literals.