-
Notifications
You must be signed in to change notification settings - Fork 120
Fix up blob columns. #913
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
Fix up blob columns. #913
Conversation
The previous PR fixed the bug where BLOB columns were incorrectly reported as 'binary' type. This commit updates all test expectations to reflect the correct behavior: - Binary/varbinary columns that auto-convert to BLOB in MySQL now correctly return as 'blob', 'tinyblob', 'mediumblob', or 'longblob' instead of incorrectly returning as 'binary' - BLOB column types now properly round-trip (blob->blob, tinyblob->tinyblob) - Fixes PHPStan error and test assertion for tinyblob SQL type This completes the fix for issue #484. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| ['tinyblob', 'tinyblob', null, MysqlAdapter::BLOB_TINY], | ||
| ['tinyblob', 'tinyblob', MysqlAdapter::BLOB_TINY, MysqlAdapter::BLOB_TINY], |
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.
How should we go about changing these types in the future? When we drop support for phinx in migrations, it would be beneficial to align with cakephp/database which uses type=binary and length parameters.
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.
Good question
I added a test case for those as well now. You can check and if necessary adjust.
How it works:
The code in MysqlAdapter.php already:
- Uses PHINX_TYPE_BINARY = TableSchemaInterface::TYPE_BINARY (line 50 in AdapterInterface.php)
- Has blob constants aligned with CakePHP: BLOB_TINY = TableSchema::LENGTH_TINY, etc. (lines 72-76)
- mapColumnData() handles both APIs and converts to CakePHP's type='binary' with length (lines 286-317)
- CakePHP's MysqlSchemaDialect generates the correct SQL (TINYBLOB, MEDIUMBLOB, etc.) based on the length
Future work (when Phinx support is dropped):
You could:
- Deprecate Phinx-style blob types (tinyblob, mediumblob, longblob)
- Remove the round-trip conversion in mapColumnType() that converts back to blob types
- Keep only 'binary' with length parameter - fully aligned with CakePHP core
- This would be a breaking change requiring coordination with a major version bump
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 had to revert, those didnt pass.
Feel free to add ammending commits to what you see fit. I just tried to get this ticket resolved.
Might resolve #484