我正在使用React Social Network框架,并在注册它后不断收到此错误。
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)
我该如何解决?
答案 0 :(得分:0)
您最有可能在(未指定的)表中插入一行,但是您忘记为列bio
指定值。
因此,您试图在列null
上插入bio
值,并且很可能将此列定义为not null
。
解决方案?要么:
在插入之前在bio
列上放置一些值。
更改表定义,并为列default
添加一个bio
值。