[英]mysql query does not see null values in nodejs
我使用来自 Rabbitmq 的消息并尝试写入 mysql。 我读过这样的消息
Object.values(JSON.parse(msg.content.toString()))
我 console.log 消费的消息如下所示;
[
null,
'2016-03-06T22:00:00.000Z',
null,
null,
796,
null,
'Weekday',
null,
null,
null,
null,
null,
'fff2d9b2-2db9-4fea-96e9-7a4ce5cdda7f',
'2022-09-08T10:42:43.876Z',
'2022-09-08T13:43:06.000Z',
'fc0cca6947244bfb546a409a5512d8bd'
]
但是当将其写入 mysql 时,它会像这样写入insert into date_d (day,date,year,month,date_id,quarter,weekend,day_of_week,day_of_year,day_of_month,week_of_year,month_of_year) values (,2015-09-27T21:00:00.000Z,,,635,,Weekday,,,,,,1bbbfb7a-64cc-46a8-bdc8-a
插入脚本如下所示
"insert into date_d (" + res + ") values (" + Object.values(JSON.parse(msg.content.toString())) + " )"
但是 mysql 删除 null 值比它给我以下错误。
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',2015-09-27T21:00:00.000Z,,,635,,Weekday,,,,,,1bbbfb7a-64cc-46a8-bdc8-a7b7a02b3e' at line 1",
任何帮助请谢谢。
本文暂无回复,试试以下方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.