Skip to content

Conversation

@dereuromark
Copy link
Member

Might resolve #484

dereuromark and others added 3 commits October 6, 2025 01:47
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>
Comment on lines +1131 to +1132
['tinyblob', 'tinyblob', null, MysqlAdapter::BLOB_TINY],
['tinyblob', 'tinyblob', MysqlAdapter::BLOB_TINY, MysqlAdapter::BLOB_TINY],
Copy link
Member

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.

Copy link
Member Author

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:

  1. Deprecate Phinx-style blob types (tinyblob, mediumblob, longblob)
  2. Remove the round-trip conversion in mapColumnType() that converts back to blob types
  3. Keep only 'binary' with length parameter - fully aligned with CakePHP core
  4. This would be a breaking change requiring coordination with a major version bump

Copy link
Member Author

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.

@markstory markstory merged commit d7ac308 into 4.x Oct 10, 2025
13 checks passed
@markstory markstory deleted the fix-blob branch October 10, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem with BLOB type when baking a migration

3 participants