-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] MySQL Grammar and Blueprint binary column fix #50354
[10.x] MySQL Grammar and Blueprint binary column fix #50354
Conversation
Some background info on WHY I do want to fix this. I am experimenting with EventSauce. An event sourcing package. It requires you to add specific binary fields to your database table. When I did use the binary method on the blueprint class, I was surprised I did get a blob field instead. Of course one can fix this by executing raw statements, but I think this is less confusing if we solve it like this. |
Adds the blob type.
This is a breaking change. Instead you may try Schema::table('test', function (Blueprint $table) {
$table->char('binary_column', 16)->charset('binary'); // binary(16)
$table->string('varbinary_column', 16)->charset('binary'); // varbinary(16)
$table->tinyText('tinyblob_column')->charset('binary'); // tinyblob
$table->text('blob_column')->charset('binary'); // blob
$table->mediumText('mediumblob_column')->charset('binary'); // mediumblob
$table->longText('longblob_column')->charset('binary'); // longblob
});
|
Wouldn't it be useful if we can have -$table->char('binary_column', 16)->collation('binary');
+$table->char('binary_column' 16)->asBinary(); |
@crynobone I think the main problem is that user expects |
Appending something to char would not be as easy as for example like adding a text column. And you could see this as a breaking change, but this functionality in my point of view was broken anyway. Simply because calling the binary method, does not add a binary field to your database. Therefore I consider it a bug. And it only could break users websites after they migrate. Upgrading would not be good enough to break your site right? |
Not going to take any action on L10 with L11 so close to release (this week or next). |
Ok. I will create the same kind of PR for Laravel 11. Oh, never mind. I see it's fixed! Thanks. |
The Blueprint class has a
binary
method that creates a blob column in your database.I added a method called
blob
that creates a blob field in the database, and I did modify thebinary
method to create a binary field instead.I've also modified the
typeBinary
method in the MySQLGrammar class so it returns 'binary' instead of 'blob' and added atypeBlob
method that returns 'blob'As a finishing touch I've modified the
testAddingBinary
in DatabaseMySqlSchemaGrammarTest.php and added thetestAddingBinary
methods to ensure the quality.