-
Notifications
You must be signed in to change notification settings - Fork 122
Add fixed option for binary column type #1014
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b4f89a7
Add fixed option for binary column type
dereuromark c8f9df3
Add test cases for fixed option on binary columns
dereuromark 24b68d4
Add column type assertions to binary fixed test
dereuromark 5d16436
Merge branch '5.x' into add-fixed-option-for-binary-type
dereuromark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3484,4 +3484,51 @@ public function testCombinedPartitionAndColumnOperations(): void | |
| $this->assertCount(1, $rows); | ||
| $this->assertEquals('A description', $rows[0]['description']); | ||
| } | ||
|
|
||
| public function testBinaryColumnWithFixedOption(): void | ||
| { | ||
| $table = new Table('binary_fixed_test', [], $this->adapter); | ||
| $table->addColumn('hash', 'binary', ['limit' => 20, 'fixed' => true]) | ||
| ->addColumn('data', 'binary', ['limit' => 20]) | ||
| ->save(); | ||
|
|
||
| $this->assertTrue($this->adapter->hasColumn('binary_fixed_test', 'hash')); | ||
| $this->assertTrue($this->adapter->hasColumn('binary_fixed_test', 'data')); | ||
|
|
||
| // Check that the fixed column is created as BINARY and the non-fixed as VARBINARY | ||
| $rows = $this->adapter->fetchAll('SHOW COLUMNS FROM binary_fixed_test'); | ||
| $hashColumn = null; | ||
| $dataColumn = null; | ||
| foreach ($rows as $row) { | ||
| if ($row['Field'] === 'hash') { | ||
| $hashColumn = $row; | ||
| } | ||
| if ($row['Field'] === 'data') { | ||
| $dataColumn = $row; | ||
| } | ||
| } | ||
|
|
||
| $this->assertNotNull($hashColumn); | ||
| $this->assertNotNull($dataColumn); | ||
| $this->assertSame('binary(20)', $hashColumn['Type']); | ||
| $this->assertSame('varbinary(20)', $dataColumn['Type']); | ||
|
|
||
| // Verify the fixed attribute is reflected back | ||
| $columns = $this->adapter->getColumns('binary_fixed_test'); | ||
| $hashCol = null; | ||
| $dataCol = null; | ||
| foreach ($columns as $col) { | ||
| if ($col->getName() === 'hash') { | ||
| $hashCol = $col; | ||
| } | ||
| if ($col->getName() === 'data') { | ||
| $dataCol = $col; | ||
| } | ||
| } | ||
|
|
||
| $this->assertNotNull($hashCol); | ||
| $this->assertNotNull($dataCol); | ||
| $this->assertTrue($hashCol->getFixed()); | ||
| $this->assertNull($dataCol->getFixed()); | ||
|
Comment on lines
+3586
to
+3591
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also have an assertion on the column types?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should eventually raise the version constraint so that we can remove this.
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.
Should we add a TODO here in code? Or just track this for a future cleanup in some ticket?