sequelize: Setting a JSON field to null saves incorrectly as string "null"

I am using Node 0.12, PostgreSQL 9.3.7, and Sequelize 3.1.1

I have a field of type JSON and when I set the value to NULL:

user.json_field = null
user.save()

the SQL generate is wrong, it uses “null” in quotes, i.e. a string with the word “null” instead of a real null:

 UPDATE "users" SET "json_field"='null', ...

How do I set it to a real null? This is a bug, right? Nobody would want NULL to be saved as a string of the word “null”.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (12 by maintainers)

Most upvoted comments

I don’t know if the issue is back, but this happened with me too. I had to improvise with “if (json.value==“null”) json.value=null;” and this annoys me XD