sequelize中paranoid导致的问题?
发布于 14 小时前 作者 suntopo 73 次浏览 来自 问答

表级联操作时: 生成sql语句:

select lite_user.id,lite_order.id from lite_user left join lite_order on lite_user.id=lite_order.merchant and lite_order.deleted_at is null where lite_user.id=2;

结果非预期

修改sql为:

select lite_user.id,lite_order.id from lite_user left join lite_order on lite_user.id=lite_order.merchant and lite_order.deleted_at='0000-00-00 00:00:00' where lite_user.id=2;
user.id=2;

得到预期结果

根据上面情况感觉是and lite_order.deleted_at出问题了,但是做如下操作时却可以的到数据,说明mysql中datetime默认值 0000-00-00 00:00:00 is null是true的.

select * from lite_order where deleted_at is null

那么问题出在哪里呢?

回到顶部