本文介绍了mysql 查询在 nodejs 中看不到 null 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
我使用来自 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",
任何帮助请谢谢。
暂无解决方案
[英文标题]mysql query does not see null values in nodejs
声明:本媒体部分图片、文章来源于网络,版权归原作者所有,如有侵权,请联系QQ:330946442删除。