db-mysql icon indicating copy to clipboard operation
db-mysql copied to clipboard

Type blob is generated instead of binary Mysql 8.0

Open RedCatGirl opened this issue 2 years ago • 3 comments

The field type binary(16) is converted to the blob type. MySQL 8.0 also has a binary type.

Example

$b->createTable('urls', [
    'id' => $b->bigPrimaryKey()->unsigned(),
    'hash' => $b->binary(16)->notNull()->comment('md5 from url')->asString(), // md5 binary
    'url' => $b->text()->notNull(),
    'create' => $b->timestamp()->notNull()->defaultExpression('CURRENT_TIMESTAMP')
]);

Result:

CREATE TABLE urls (
    id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    hash blob NOT NULL COMMENT 'md5 from url',
    url text NOT NULL,
    create timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP
);

RedCatGirl avatar Feb 23 '23 15:02 RedCatGirl

Please version Mysql .

terabytesoftw avatar Feb 23 '23 15:02 terabytesoftw

Please version Mysql .

My version: mysql Ver 8.0.32-0ubuntu0.20.04.2 for Linux on x86_64

RedCatGirl avatar Feb 23 '23 15:02 RedCatGirl

https://github.com/yiisoft/yii2/blob/f388ca71b08b89e940f1ffbe4afa19ae9d5e115f/framework/db/mysql/QueryBuilder.php#L45 Here is the mapping to blob, we'll check.

terabytesoftw avatar Feb 23 '23 15:02 terabytesoftw