Skip to content

Conversation

@dereuromark
Copy link
Member

@dereuromark dereuromark commented Jan 28, 2026

Summary

  • Adds support for the fixed attribute on binary columns to distinguish between fixed-length BINARY and variable-length VARBINARY types
  • When reflecting a BINARY(n) column from the database, fixed => true is now passed through to the Column object
  • When baking migrations, the fixed option is now included in the generated migration code

This is the companion PR to cakephp/cakephp#19207 which adds the core framework support for this feature.

Usage

// Creates VARBINARY(20) - variable length (default)
$table->addColumn('data', 'binary', ['length' => 20]);

// Creates BINARY(20) - fixed length  
$table->addColumn('hash', 'binary', ['length' => 20, 'fixed' => true]);

Refs #999


Constraint: This one doesnt technically need one.

Also, even if, since #1013 is raising the constraint already, I skipped it for this PR here.

Add support for the `fixed` attribute on binary columns to distinguish
between fixed-length BINARY and variable-length VARBINARY types.
This mirrors cakephp/cakephp#19207.
Tests cover:
- Column class getter/setter for fixed option
- Column::toArray() including fixed in output
- Column::setOptions() accepting fixed option
- MigrationHelper::getColumnOption() including/excluding fixed
- MysqlAdapter creating BINARY vs VARBINARY based on fixed option
Comment on lines +788 to +793
public function setFixed(bool $fixed)
{
$this->fixed = $fixed;

return $this;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should eventually raise the version constraint so that we can remove this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we add a TODO here in code? Or just track this for a future cleanup in some ticket?

Comment on lines 3529 to 3532
$this->assertNotNull($hashCol);
$this->assertNotNull($dataCol);
$this->assertTrue($hashCol->getFixed());
$this->assertNull($dataCol->getFixed());
Copy link
Member

Choose a reason for hiding this comment

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

Should we also have an assertion on the column types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@dereuromark
Copy link
Member Author

We need to wait with final merge and bugfix release until core patch has been released it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants