-
-
Notifications
You must be signed in to change notification settings - Fork 16
Refactor ColumnDefinitionParser
#447
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #447 +/- ##
============================================
+ Coverage 98.70% 98.75% +0.04%
- Complexity 252 254 +2
============================================
Files 24 24
Lines 775 801 +26
============================================
+ Hits 765 791 +26
Misses 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR refactors the ColumnDefinitionParser class to extend from AbstractColumnDefinitionParser instead of the concrete ColumnDefinitionParser class from the parent yiisoft/db package, aligning with architectural changes in the base library. The refactoring adds MySQL-specific parsing logic for enum types and type parameters.
- Migrates from extending
\Yiisoft\Db\Syntax\ColumnDefinitionParsertoAbstractColumnDefinitionParser - Implements MySQL-specific
parseTypeParams()method with support for enum values - Adds corresponding test coverage for enum type parsing
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Column/ColumnDefinitionParser.php | Refactored to extend AbstractColumnDefinitionParser and added MySQL-specific parseTypeParams() and parseEnumValues() methods for handling enum types and other type parameters |
| tests/ColumnDefinitionParserTest.php | Added new test class for column definition parser with data provider integration (missing namespace declaration) |
| tests/Provider/ColumnDefinitionParserProvider.php | Added test data provider with enum-specific test cases |
| CHANGELOG.md | Added changelog entry documenting the breaking change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| return match ($type) { | ||
| 'bit', | ||
| 'bigint', | ||
| 'binary', | ||
| 'char', | ||
| 'decimal', | ||
| 'double', | ||
| 'float', | ||
| 'int', | ||
| 'integer', | ||
| 'mediumint', | ||
| 'numeric', | ||
| 'real', | ||
| 'smallint', | ||
| 'string', | ||
| 'tinyint', | ||
| 'varbinary', | ||
| 'varchar', | ||
| 'year' => $this->parseSizeInfo($params), | ||
| 'enum' => $this->parseEnumValues($params), | ||
| default => [], | ||
| }; |
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.
| return match ($type) { | |
| 'bit', | |
| 'bigint', | |
| 'binary', | |
| 'char', | |
| 'decimal', | |
| 'double', | |
| 'float', | |
| 'int', | |
| 'integer', | |
| 'mediumint', | |
| 'numeric', | |
| 'real', | |
| 'smallint', | |
| 'string', | |
| 'tinyint', | |
| 'varbinary', | |
| 'varchar', | |
| 'year' => $this->parseSizeInfo($params), | |
| 'enum' => $this->parseEnumValues($params), | |
| default => [], | |
| }; | |
| return match ($type) { | |
| 'enum' => $this->parseEnumValues($params), | |
| default => $this->parseSizeInfo($params), | |
| }; |
It seems a mistake to limit the list of types for parsing.
We use column definition parser not only for native db types but for abstract types also.
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.
What case for abstract types?
Related to yiisoft/db#1108