mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.22k stars 2.53k forks source link

ER_NO_DEFAULT_FOR_FIELD #2495

Closed shengzhou1216 closed 2 years ago

shengzhou1216 commented 3 years ago

Below is the log outputs:

RowDataPacket { id: 205 } 60c8040e4afcf7001cfa4a04
{
  status: undefined,
  event: 'UpdateDueAt',
  created_at: 2021-06-19T12:56:32.000Z,
  updated_at: 2021-06-19T12:56:32.000Z,
  sub_ticket_id: 205
}
RowDataPacket { id: 210 } 60d1d79d4afcf7001cfa4a7a
{
  status: 'Assigned',
  event: 'UpdateStatus',
  created_at: 2021-06-22T12:29:17.000Z,
  updated_at: 2021-06-22T12:29:17.000Z,
  sub_ticket_id: 210
}
2021-06-25 14:55:08 error: ER_NO_DEFAULT_FOR_FIELD: Field 'sub_ticket_id' doesn't have a default value Error: ER_NO_DEFAULT_FOR_FIELD: Field 'sub_ticket_id' doesn't have a default value

record:60c8040e4afcf7001cfa4a04 insert succeed , but record:60d1d79d4afcf7001cfa4a7a insert failed. Why?

dougwilson commented 2 years ago

Hi @shengzhou1216 sorry there was no response for a while. The error you are getting is from your MySQL server, that your table does not define a default value for the sub_ticket_id column, so you cannot perform an INSERT on that table without supplying a value for the sub_ticket_id column in the new row.