alibaba / druid

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

正确的sql, 执行时 parse 报错, 版本 1.1.6 #3440

Open zhouvtp opened 5 years ago

zhouvtp commented 5 years ago

select j.id as jkid, u.id as id ,f.realName , u.mobilePhone,u.username, j.jk_money, j.jk_date ,j.sjsh_money ,j.sjds_money , j.sfyfk, j.fkdz_time,j.hkyq_time,j.hkfq_time,j.hkfq_code,j.hkfq_cishu,j.sfyhw ,j.yuq_lx ,j.cuishou_id,(select c.create_time from sd_csmsg c where c.id = (select max(m.id) from sd_csmsg m where m.jkid = j.id)) as create_time ,(select c.msg from sd_csmsg c where c.id = (select max(m.id) from sd_csmsg m where m.jkid = j.id)) as msg, j.hk_time, j.lx from sd_new_jkyx j left join sd_user u on j.userid = u.id LEFT join sd_user_finance f on f.userId =j.userid where j.sfyfk <>0 and j.sfyhw=0 and ( (str_to_date(j.hkyq_time,'%d-%m-%Y %H:%i:%s') >= {ts '2019-08-30 00:00:00'} and str_to_date(j.hkyq_time,'%d-%m-%Y %H:%i:%s') < {ts '2019-09-02 00:00:00'}) or (str_to_date(j.hkfq_time,'%d-%m-%Y %H:%i:%s') >= {ts '2019-08-30 00:00:00'} and str_to_date(j.hkfq_time,'%d-%m-%Y %H:%i:%s') < {ts '2019-09-02 00:00:00'}) ) and j.cuishou_id in (2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020) order by j.hkyq_time limit 0,1 com.alibaba.druid.sql.parser.ParserException: ERROR. pos 675, line 1, column 674, token LBRACE at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:787) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:185) at com.alibaba.druid.sql.parser.SQLExprParser.bitXor(SQLExprParser.java:118) at com.alibaba.druid.sql.parser.SQLExprParser.multiplicative(SQLExprParser.java:205) at com.alibaba.druid.sql.parser.SQLExprParser.additive(SQLExprParser.java:1825) at com.alibaba.druid.sql.parser.SQLExprParser.shift(SQLExprParser.java:1855) at com.alibaba.druid.sql.parser.SQLExprParser.bitAnd(SQLExprParser.java:1635) at com.alibaba.druid.sql.parser.SQLExprParser.bitOr(SQLExprParser.java:1649) at com.alibaba.druid.sql.parser.SQLExprParser.relationalRest(SQLExprParser.java:2053) at com.alibaba.druid.sql.parser.SQLExprParser.exprRest(SQLExprParser.java:109) at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:97) at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:280) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:185) at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:86) at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:280) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:185) at com.alibaba.druid.sql.parser.SQLExprParser.bitXor(SQLExprParser.java:118) at com.alibaba.druid.sql.parser.SQLExprParser.multiplicative(SQLExprParser.java:205) at com.alibaba.druid.sql.parser.SQLExprParser.additive(SQLExprParser.java:1825) at com.alibaba.druid.sql.parser.SQLExprParser.shift(SQLExprParser.java:1855) at com.alibaba.druid.sql.parser.SQLExprParser.bitAnd(SQLExprParser.java:1635) at com.alibaba.druid.sql.parser.SQLExprParser.bitOr(SQLExprParser.java:1649) at com.alibaba.druid.sql.parser.SQLExprParser.equality(SQLExprParser.java:1669) at com.alibaba.druid.sql.parser.SQLExprParser.relational(SQLExprParser.java:2005) at com.alibaba.druid.sql.parser.SQLExprParser.andRest(SQLExprParser.java:1907) at com.alibaba.druid.sql.parser.SQLExprParser.exprRest(SQLExprParser.java:111) at com.alibaba.druid.sql.parser.SQLSelectParser.parseWhere(SQLSelectParser.java:358) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlSelectParser.query(MySqlSelectParser.java:176) at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:59) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseSelect(MySqlStatementParser.java:114) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:147) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:70) at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:78) at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:49) at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:147) at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:648) at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:311) at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:473) at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:929) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:473) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:349) at com.thinkive.base.jdbc.session.Impl.SessionImpl.queryFromSpecialDB(SessionImpl.java:1133) at com.thinkive.base.jdbc.session.Impl.SessionImpl.query(SessionImpl.java:1014) at com.thinkive.base.jdbc.session.Impl.SessionImpl.queryPage(SessionImpl.java:1220) at com.thinkive.base.jdbc.session.Impl.SessionImpl.queryPage(SessionImpl.java:1182) at com.thinkive.base.jdbc.JdbcTemplate.queryPage(JdbcTemplate.java:782) at com.project.service.account.CmsSupportService.getRecordJRList(CmsSupportService.java:1131)

zhouvtp commented 5 years ago

mysql 的一种 timestamp 写法 {ts '2019-08-30 00:00:00'} 不支持, 版本一直到 1.19 都有问题