Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: 'NULL' #107

Open
antongorodezkiy opened this issue Aug 13, 2016 · 1 comment
Open

ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: 'NULL' #107

antongorodezkiy opened this issue Aug 13, 2016 · 1 comment
Assignees
Labels

Comments

@antongorodezkiy
Copy link

Hello friends,

I got the following error when trying set timestamp column (it's allows NULL) to NULL.

Potentially unhandled rejection [1] Error: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: 'NULL' for column 'added_to_queue_at' at row 1

When trying to call the following code:

model.added_to_queue_at = null;
model.save();

The following code isn't work either:

model.added_to_queue_at = undefined;
model.save();

Schema:

let Word = Schema.define('Word', {
  id:                { type: Number },
  added_to_queue_at: { type: Date, dataType: 'timestamp', allowNull: true, null: true, default: () => { return null;} }
}, {
  table: 'word'
});

In the current version of node-mysql it works fine with undefined:

connection.query('UPDATE `words` SET `added_to_queue_at` = ? WHERE id = ?', [
  undefined,
  18
], function(err, results) {
  console.error(err);
  console.log(results);
});
@antongorodezkiy
Copy link
Author

antongorodezkiy commented Aug 13, 2016

For now I'm using the following workaround:

Word.update({
  where: {
    id: word.id
  },
  update: {
    added_to_queue_at: undefined
  }
});

@1602 1602 self-assigned this Aug 13, 2016
@1602 1602 added the bug label Aug 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants