Skip to content

fix: checking the state of a database with a binary field. - #240

Open
AZabolotnikov wants to merge 94 commits into
masterfrom
azabolotnikov/fix-db-check-binary-field
Open

fix: checking the state of a database with a binary field.#240
AZabolotnikov wants to merge 94 commits into
masterfrom
azabolotnikov/fix-db-check-binary-field

Conversation

@AZabolotnikov

@AZabolotnikov AZabolotnikov commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

If a DB table has a binary field, the field displays as null when checking the database state.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes an issue where binary fields were displaying as null when checking database state. The fix adds support for detecting and properly serializing binary data fields by converting them to hexadecimal representation.

Changes:

  • Added binary field handling logic that detects binary data using UTF-8 encoding validation
  • Created test infrastructure including a BinaryCast class and test cases to verify binary field state tracking
  • Updated test expectations to include the new binary_field in the TestModel

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Testing/TableTestState.php Core fix that detects binary data and converts it to hex representation before comparison
tests/support/Mock/Casts/BinaryCast.php New custom cast implementation for testing binary field behavior
tests/support/Mock/Models/TestModel.php Added binary_field to the test model for testing purposes
tests/ModelTestStateTest.php Added test case for binary field changes and updated expectations
tests/BaseRequestTest.php Updated test expectations to include binary_field in orderable fields
tests/fixtures/ModelTestStateTest/db_changes/test_models/assert_changes_binary_string.json Test fixture defining expected state changes for binary field updates

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

Comment thread tests/ModelTestStateTest.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
Comment thread src/Testing/TableTestState.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


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

Comment thread tests/ModelTestStateTest.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


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

Comment thread src/Testing/TableTestState.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Comment thread tests/support/Mock/Models/TestModel.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
@DenTray DenTray assigned AZabolotnikov and unassigned DenTray Jan 26, 2026
@AZabolotnikov

AZabolotnikov commented Jan 28, 2026

Copy link
Copy Markdown
Contributor Author

@DenTray I did a small research and found the following problem with the binary field:

  $this->exportJson('export_json/response.json', [
            'some_key' => md5('some_string', true),
        ]);

But I think this case is related only to the database test, because we get data from the DB facade , we should use bin2hex to cast the field inside test for model state

@AZabolotnikov
AZabolotnikov requested a review from DenTray January 28, 2026 10:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


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

Comment thread tests/ModelTestStateTest.php Outdated
Comment thread tests/ModelTestStateTest.php Outdated
Comment thread tests/support/Mock/Casts/BinaryCast.php
Comment thread src/Testing/TableTestState.php Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AZabolotnikov
AZabolotnikov requested a review from Copilot January 28, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/Testing/TableTestState.php
Comment thread tests/support/Traits/TableTestStateMockTrait.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

yburlakov and others added 3 commits May 20, 2026 12:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread src/Testing/TableTestState.php Outdated
Comment thread src/Testing/TableTestState.php Outdated
Comment thread tests/support/Mock/Casts/BinaryCast.php Outdated
Comment thread tests/support/Mock/Casts/BinaryCast.php Outdated
Comment on lines +53 to +61
$builderMock
->method('select')
->with('column_name')
->willReturnSelf();

$builderMock
->method('where')
->with('table_name', 'test_models')
->willReturnSelf();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could we simplify this method and use mockSelect method to assert that script made expected select query?

{
"updated": [],
"created": [],
"deleted": [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks strange, it should contains only updated

AZabolotnikov and others added 8 commits June 3, 2026 13:17
Co-authored-by: DenTray <dpankratov@ronasit.com>
Co-authored-by: DenTray <dpankratov@ronasit.com>
Co-authored-by: DenTray <dpankratov@ronasit.com>
Co-authored-by: DenTray <dpankratov@ronasit.com>
…y-field' into azabolotnikov/fix-db-check-binary-field

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

@DenTray

DenTray commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

@AZabolotnikov please resolve conflicts

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.

4 participants