generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fixes #3 - Issues related to Blob/Binary data type #4
Merged
Merged
Changes from all commits
Commits
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 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 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 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
beforeEach(function () { | ||
Schema::create('blob_table', function ($table) { | ||
$table->id(); | ||
$table->binary('blob'); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
Schema::dropIfExists('blob_table'); | ||
}); | ||
|
||
test('it can insert a new blob data', function () { | ||
$data = random_bytes(50); | ||
|
||
$result = DB::table('blob_table')->insert([ | ||
'blob' => $data, | ||
]); | ||
|
||
$newData = DB::table('blob_table')->first(); | ||
|
||
expect($result)->toBeTrue() | ||
->and(DB::table('blob_table')->count())->toBe(1) | ||
->and($newData->blob)->toBe($data); | ||
})->group('BlobDataTest', 'DataTypes', 'FeatureTest'); | ||
|
||
test('it can update an existing blob data', function () { | ||
$data = random_bytes(50); | ||
|
||
DB::table('blob_table')->insert([ | ||
'blob' => $data, | ||
]); | ||
|
||
$newData = random_bytes(50); | ||
|
||
$result = DB::table('blob_table')->update([ | ||
'blob' => $newData, | ||
]); | ||
|
||
$updatedData = DB::table('blob_table')->first(); | ||
|
||
expect($result)->toBe(1) | ||
->and($updatedData->blob)->toBe($newData); | ||
})->group('BlobDataTest', 'DataTypes', 'FeatureTest'); |
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.
Passing the binary/blob data with a single base64 encoding produces an intermittent error. I've reported this issue to the Turso development team. As a quick fix to avoid the error, we will send the binary/blob data by encoding it in base64 format twice.
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.
That's kinda wild
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.
Yeah, this is only a quick fix. I will update the approach as soon as the Turso dev team fixes the issue. There's also a workaround to store binary data as a base64-encoded string in the database using Laravel's custom attribute casting.
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.
Anyway.. Do you have any suggestions about 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.
If it works, it works. Interested to hear what Turso have to say .
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.
They're currently investigating the issue. You can find the issue report I've submitted on Turso's Discord server in the
help
channel.