今天在开发springcloud微服务框架下功能时,PG数据库一条sql报错:
Cause: org.postgresql.util.PSQLException: 错误: 操作符不存在: date >= character varying 建议:没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换. 位置:345
其实框架提示的很清楚了,改动也很简单,例子如下

// 原来的
<if test="endDate_start != '' and endDate_end != '' and endDate_start != null and endDate_end != null "> 
	and b.enddate between #{endDate_start} and #{endDate_end}	
</if>
// 改动后的
<if test="endDate_start != '' and endDate_end != '' and endDate_start != null and endDate_end != null "> 
	and b.enddate between CAST( #{endDate_start} as date) and CAST( #{endDate_end} as date)	
</if>
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐