Skip to content
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

MySQL 8.0 无法创建企业临时解决方案 #76

Closed
maxincai opened this issue Mar 18, 2021 · 2 comments
Closed

MySQL 8.0 无法创建企业临时解决方案 #76

maxincai opened this issue Mar 18, 2021 · 2 comments

Comments

@maxincai
Copy link
Contributor

maxincai commented Mar 18, 2021

修改文件 :vendor/hyperf/database/src/Schema/Grammars/MySqlGrammar.php

找到 compileColumnListing 方法,修改如下:

 /**
     * Compile the query to determine the list of columns.
     */
    public function compileColumnListing(): string
    {
        return 'select `column_key` as `column_key`, `column_name` as `column_name`, `data_type` as `data_type`, `column_comment` as `column_comment`, `extra` as `extra`, `column_type` as `column_type` from information_schema.columns where `table_schema` = ? and `table_name` = ? order by ORDINAL_POSITION';
    }
@maxincai
Copy link
Contributor Author

maxincai commented Mar 24, 2021

以上方法重新 composer install 之后会被覆盖。可以采用以下方式

mochat/api-server/app/Utils/ 目录新建文件 MySqlGrammar.php,内容如下

<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
namespace App\Utils;

class MySqlGrammar extends \Hyperf\Database\Schema\Grammars\MySqlGrammar
{
     /**
     * Compile the query to determine the list of columns.
     */
    public function compileColumnListing(): string
    {
        return 'select `column_key` as `column_key`, `column_name` as `column_name`, `data_type` as `data_type`, `column_comment` as `column_comment`, `extra` as `extra`, `column_type` as `column_type` from information_schema.columns where `table_schema` = ? and `table_name` = ? order by ORDINAL_POSITION';
    }
}

修改配置文件 api-server/config/autoload/dependencies.php

return $dependencies + [
];

改为

return $dependencies + [
     Hyperf\Database\Schema\Grammars\MySqlGrammar::class => App\Utils\MySqlGrammar::class
];

@maxincai
Copy link
Contributor Author

新版本中已经更新,旧版本执行 composer update mochat/framework 即可。

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

No branches or pull requests

1 participant