Postgresql like错误的坑(ERROR: could not determine data type of parameter $7)

在测试环境模糊查询的使用 的是Mybatis
模糊查询的写法是

select * from test
where
name like CONCAT('%',#{marketInsightDTO.drugName},'%')

测试环境没有报错

然后上到生产就报错
错误日志

### Cause: org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $7
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $7
org.springframework.jdbc.BadSqlGrammarException: 

拿到sql去生产数据库执行也是没问题的

初步分析应该是postgresql版本的原因,上面的错误也很明显 大致就是 无法确定参数类型,我们简单的做一个强制转换就可以了
使用 ::text

like CONCAT('%',#{marketInsightDTO.drugName}::text,'%')

然后去查询发现测试环境Postgresql 版本为:
PostgreSQL 11.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit

生产为:
PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4), 64-bit

  • 13
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值