Skip to content

Conversation

@vjik
Copy link
Member

@vjik vjik commented Nov 25, 2025

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (853feda) to head (3d8f279).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1108   +/-   ##
=========================================
  Coverage     98.62%   98.62%           
+ Complexity     1648     1647    -1     
=========================================
  Files           119      119           
  Lines          4280     4280           
=========================================
  Hits           4221     4221           
  Misses           59       59           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samdark samdark requested a review from Copilot November 25, 2025 21:14
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
Copy link
Contributor

Copilot AI left a 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 into an abstract base class (AbstractColumnDefinitionParser) with a new interface (ColumnDefinitionParserInterface). The refactoring extracts database-specific type parameter parsing (such as enum value extraction and size/scale parsing) into an abstract method parseTypeParams(), which must be implemented by database-specific parsers in related packages (MySQL, PostgreSQL, MSSQL, Oracle, SQLite). This improves separation of concerns and allows each database driver to handle type-specific parsing according to its own syntax requirements.

Key changes:

  • Introduced ColumnDefinitionParserInterface defining the contract for column definition parsers
  • Renamed ColumnDefinitionParser to AbstractColumnDefinitionParser and made it abstract with parseTypeParams() method
  • Removed enum-specific parsing from the base class (moved to database-specific implementations)
  • Updated test infrastructure with stub implementations and adjusted test cases

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Syntax/ColumnDefinitionParserInterface.php New interface defining the column definition parser contract
src/Syntax/AbstractColumnDefinitionParser.php Refactored from concrete class to abstract class, extracted type parameter parsing to abstract method
src/Schema/Column/AbstractColumnFactory.php Changed columnDefinitionParser() from concrete to abstract method returning interface
tests/Support/Stub/StubColumnDefinitionParser.php New stub implementation for testing purposes
tests/Support/Stub/StubColumnFactory.php Added implementation of abstract columnDefinitionParser() method
tests/Common/CommonColumnDefinitionParserTest.php Updated to use interface and made createColumnDefinitionParser() abstract
tests/Provider/ColumnDefinitionParserProvider.php Removed enum test cases (moved to database-specific tests)
tests/Db/Schema/Column/ColumnFactoryTest.php Updated data provider usage and removed size assertion for stub tests
tests/Common/CommonColumnTest.php Code formatting improvement (multi-line array_map)
UPGRADE.md Documented breaking changes and API modifications
CHANGELOG.md Added entry for the refactoring
.github/workflows/db-mariadb.yml Added YII_MYSQL_TYPE environment variable for MariaDB distinction
Comments suppressed due to low confidence (1)

src/Syntax/AbstractColumnDefinitionParser.php:92

  • The return type annotation at line 82 declares the fourth element as string|null, but substr() at line 92 always returns a string (never null). This creates an inconsistency in the type declaration.

Consider updating the return type to:

@psalm-return list{string, string|null, string|null, string}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +13
protected function parseTypeParams(string $type, string $params): array
{
return [];
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StubColumnDefinitionParser returns an empty array from parseTypeParams(), which means it doesn't parse type parameters like size and scale. However, test data in ColumnFactoryTest.php includes definitions with parameters (e.g., 'char(1)', 'decimal(10,2)' at lines 90-91) that won't be parsed.

Consider implementing basic parameter parsing in the stub:

protected function parseTypeParams(string $type, string $params): array
{
    return $this->parseSizeInfo($params);
}

This would make the stub more realistic and allow proper testing of size/scale parsing.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not to use return $this->parseSizeInfo($params); as AI suggests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends by type. Different types requires different parsing. This is DBMS-specific thing.

@vjik vjik requested a review from a team November 25, 2025 21:35
@vjik vjik added the status:code review The pull request needs review. label Nov 25, 2025
@vjik vjik requested a review from samdark November 25, 2025 21:36
@vjik vjik added status:under development Someone is working on a pull request. and removed status:code review The pull request needs review. labels Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:under development Someone is working on a pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants