alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.95k stars 8.58k forks source link

ERROR c.a.druid.filter.stat.StatFilter - merge sql error, dbType com.alibaba.druid.pool.DruidDataSource, druid-1.1.24, sql #3952

Closed TomYule closed 4 years ago

TomYule commented 4 years ago

错误信息

elAdmin- 2020-09-18 15:39:43 [http-nio-8000-exec-3] INFO  jdbc.sqlonly - select d.id, b.contract_date as contractDate, d.contract_no, d.brand_code as brandCode, d.num, 
(SELECT COALESCE(sum(num1), 0) FROM tc_order_record WHERE tc_order_record.contract_no = d.contract_no) 
orderSumNum, (SELECT (COALESCE(d.num, 0) - COALESCE(sum(num1), 0)) FROM tc_order_record WHERE 
tc_order_record.contract_no = d.contract_no ) avai from tc_contract_detail as d left join tc_contract_base 
b on d.contract_no = b.contract_no where b.data_transfer_flag = '3' and if(''!='',d.contract_no='',1=1) 
and if(''!='', d.brand_code ='',1=1) and if(NULL!='', b.contract_date >=NULL,1=1) and if(NULL!='', 
b.contract_date <=NULL,1=1) order by b.contract_date desc, d.id desc limit 10 

elAdmin- 2020-09-18 15:39:43 [http-nio-8000-exec-3] ERROR c.a.druid.filter.stat.StatFilter - merge sql error, dbType com.alibaba.druid.pool.DruidDataSource, druid-1.1.24, sql : select count(WHERE) FROM tc_order_record WHERE tc_order_record.contract_no = d.contract_no) orderSumNum,  (SELECT (COALESCE(d.num, 0) - COALESCE(sum(num1), 0))   FROM tc_order_record   WHERE tc_order_record.contract_no = d.contract_no   ) avai  from tc_contract_detail as d left join tc_contract_base b on d.contract_no = b.contract_no  where b.data_transfer_flag = '3' and if(?!='',d.contract_no=?,1=1) and if(?!='', d.brand_code =?,1=1) and if(?!='', b.contract_date >=?,1=1) and if(?!='', b.contract_date <=?,1=1)
com.alibaba.druid.sql.parser.ParserException: ERROR. pos 18, line 1, column 14, token WHERE

druid-1.1.24, SQL能正常运行

select
  d.id,
  b.contract_date as                              contractDate,
  d.contract_no,
  d.brand_code    as                              brandCode,
  d.num,
  (SELECT COALESCE(sum(num1), 0)  FROM tc_order_record  WHERE tc_order_record.contract_no = d.contract_no)  orderSumNum,
  (SELECT (COALESCE(d.num, 0) - COALESCE(sum(num1), 0))  FROM tc_order_record  WHERE tc_order_record.contract_no = d.contract_no) avai
from tc_contract_detail as d left join tc_contract_base  b on d.contract_no = b.contract_no
where b.data_transfer_flag = '3' and if('' != '', d.contract_no = '', 1 = 1)
      and if('' != '', d.brand_code = '', 1 = 1) and if(NULL != '', b.contract_date >= NULL, 1 = 1) and if(NULL != '',   b.contract_date <= NULL, 1 = 1)
order by b.contract_date desc, d.id desc
limit 10

请问 是哪里 出了问题呢

wenshao commented 4 years ago

dbType配置错了吧?是mysql?