字段 'cover' 没有默认值

Field 'cover' doesn't have a default value

我正在使用 tx_sfbooks 扩展程序将图书添加到我的网站。

当我添加一条新记录时,出现以下错误:

2: SQL error: 'Field 'cover' doesn't have a default value' (tx_sfbooks_domain_model_book:NEW60807a6c5dce2359862008)

我试图在 table tx_sfbooks_domain_model_book 中为字段 cover 添加默认值,但我在 mysql 上收到错误,因为该字段是 BLOB类型。

我也试过禁用严格 SQL 模式:

但总是出现同样的错误。

这是架构:

#
# Table structure for table 'tx_sfbooks_domain_model_book'
#
CREATE TABLE tx_sfbooks_domain_model_book
(
    number       tinytext                     NOT NULL,
    title        tinytext                     NOT NULL,
    path_segment varchar(2048),
    subtitle     tinytext                     NOT NULL,
    author       tinytext                     NOT NULL,
    isbn         tinytext                     NOT NULL,
    series       int(11) unsigned DEFAULT '0' NOT NULL,
    category     int(11) unsigned DEFAULT '0' NOT NULL,
    description  text                         NOT NULL,
    extras       blob                         NOT NULL,
    cover        blob                         NOT NULL,
    cover_large  blob                         NOT NULL,
    sample_pdf   blob                         NOT NULL,
    year         varchar(4)       DEFAULT ''  NOT NULL,
    location1    int(11) unsigned DEFAULT '0' NOT NULL,
    location2    int(11) unsigned DEFAULT '0' NOT NULL,
    location3    int(11) unsigned DEFAULT '0' NOT NULL
);

我正在使用 MySQL 8.0.23

我通过关闭 Mysql strict mode 解决了这个问题,通过这个命令:

mysql -u root -p -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';" 

为了验证,运行 这个命令:

 mysql -u root -p -e "SELECT @@GLOBAL.sql_mode;"

你应该看到:

+---------------+------------------------+
| Variable_name | Value                  |
+---------------+------------------------+
| sql_mode      | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+