【问题详细描述】
执行sql语句: select count( * ) from table where _id in (23705) 时成功
执行sql语句: select count( * ) from table where _id in (23705, 0) 时报以下错误:
WARNING: Connot convert constant value to BSON
HINT: Constant value data type: 1016
WARNING: convert value failed: key=$in
【问题分析】
1、当in操作符中包含多个字段时,pg内部将视为数组类型。
2、上例中,参数被识别为bigint数组,而不是bigint,因此无法识别,抛出错误。
【解决方法】
可以先单个条件写, 然后把结果union
如:select * from table where a = 23705 uion select * from table where a = 0
【参考链接】
错误码
常见错误处理指南