我使用的是react社交网络框架,注册后不断出现此错误。
Unhandled rejection Error: ER_NO_DEFAULT_FOR_FIELD: Field 'bio' doesn't have a default value
at Query.Sequence._packetToError (/var/www/example.com/public_html/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/var/www/example.com/public_html/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
at Protocol._parsePacket (/var/www/example.com/public_html/node_modules/mysql/lib/protocol/Protocol.js:278:23)
at Parser.write (/var/www/example.com/public_html/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/var/www/example.com/public_html/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/var/www/example.com/public_html/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/var/www/example.com/public_html/node_modules/mysql/lib/Connection.js:502:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onread (net.js:638:20)
--------------------
at Protocol._enqueue (/var/www/example.com/public_html/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Connection.query (/var/www/example.com/public_html/node_modules/mysql/lib/Connection.js:200:25)
at bcrypt.hash (/var/www/example.com/public_html/models/db.js:18:10)
at /var/www/example.com/public_html/node_modules/bcrypt-nodejs/bCrypt.js:631:3
at process._tickCallback (internal/process/next_tick.js:61:11)
我该怎么解决这个问题?
1条答案
按热度按时间xdnvmnnf1#
很可能是在(未指定的)表中插入了一行,但忘记了指定列的值
bio
.因此,您正在尝试插入
null
列上的值bio
,此列很可能定义为not null
.解决方案?或者:
把一些价值放在
bio
插入前的列。更改表定义并添加
default
列的值bio
.