-
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
Fixes unable to create MySQL database with null
collation using Schema::createDatabase()
#48886
Conversation
…hema::createDatabase()` Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
@@ -43,11 +43,13 @@ class MySqlGrammar extends Grammar | |||
*/ | |||
public function compileCreateDatabase($name, $connection) | |||
{ | |||
$collation = $connection->getConfig('collation'); | |||
|
|||
return sprintf( | |||
'create database %s default character set %s default collate %s', |
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.
@Jubeki can you confirm this can generate the correct SQL?
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.
Seems like for Mysql this results in the following:
use Illuminate\Database\Schema\Grammars\MySqlGrammar;
$grammar = new MySqlGrammar();
return $grammar->compileCreateDatabase('test', DB::connection());
// create database `test` default character set `utf8mb4` default collate
Result of execution of the sql query:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
(I will also take a look at the linked issue later today)
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.
I tested the current laravel/laravel
against Laravel Sail, I don't have any other DB on may Laptop.
Simplest solution would probably be to revert my PR @crynobone, and simply add another config entry for Laravel 11. (see my framework PR)
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.
@Jubeki just something to consider for Laravel 11, Schema::createDatabase()
is used in Parallel testing and similar issue will still persist in Laravel 11 if collation
configuration is null
.
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, for Laravel 11 was the idea to create the new mariadb config entry with the default collation set for both mariadb and mysql. (see #48455)
Reverted laravel/laravel#6241 |
Reported via orchestral/testbench-core#148