Conversation
String defaults are always quoted in a column definition, so an unquoted NULL can only be SQL NULL. Previously it was stored as defaultValueRaw 'NULL' and the MySQL column factory typecast it to 0 for integer columns (e.g. 'int DEFAULT NULL' was created as DEFAULT 0). See yiisoft/db-mysql#485
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1202 +/- ##
=========================================
Coverage 98.63% 98.63%
- Complexity 1653 1655 +2
=========================================
Files 123 123
Lines 4309 4311 +2
=========================================
+ Hits 4250 4252 +2
Misses 59 59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vjik
approved these changes
Oct 1, 2026
Comment on lines
+18
to
+19
| - Bug #1202: Fix `ColumnDefinitionParser` to parse an unquoted `DEFAULT NULL` as SQL `NULL` instead of the string | ||
| `'NULL'`, which MySQL typecast to `DEFAULT 0` for integer columns (@Lugat) |
Member
There was a problem hiding this comment.
Suggested change
| - Bug #1202: Fix `ColumnDefinitionParser` to parse an unquoted `DEFAULT NULL` as SQL `NULL` instead of the string | |
| `'NULL'`, which MySQL typecast to `DEFAULT 0` for integer columns (@Lugat) | |
| - Bug #1202: Fix `ColumnDefinitionParser` to parse an unquoted `DEFAULT NULL` as SQL `NULL` instead of the string | |
| `'NULL'` (@Lugat) |
Tigrov
approved these changes
Oct 2, 2026
| $extra = $this->parseBoolValue($extra, '/\s*\bUNIQUE\b/i', 'unique', $info); | ||
| $extra = $this->parseBoolValue($extra, '/\s*\bNOT\s+NULL\b/i', 'notNull', $info); | ||
|
|
||
| // String defaults are always quoted in a column definition, so an unquoted `NULL` can only be SQL `NULL` |
Member
There was a problem hiding this comment.
Suggested change
| // String defaults are always quoted in a column definition, so an unquoted `NULL` can only be SQL `NULL` |
This comment looks redundant
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As discussed in yiisoft/db-mysql#485: an unquoted
NULLafterDEFAULTwas stored asdefaultValueRaw = 'NULL'. The MySQLColumnFactorytypecasts it by column type, soint DEFAULT NULLwas created asDEFAULT 0. This breaks theyiisoft/queue-dbmigration: messages are never reserved becausereserved_at IS NULLnever matches.String defaults are always quoted in a column definition, so an unquoted
NULLcan only be SQLNULL. It is now parsed asdefaultValueRaw = null. Schema reading frominformation_schemais not affected, sovarchar DEFAULT 'NULL'keeps working.Checked on MySQL 8.0:
int DEFAULT NULL→DEFAULT NULL(wasDEFAULT 0);int DEFAULT 5andvarchar(10) DEFAULT 'NULL'are unchanged.