baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.67k stars 1.19k forks source link

mybatis postgresql sql error with "AT TIME ZONE" or "INTERVAL 'x' DAY", etc. #209

Closed oulaly closed 4 years ago

oulaly commented 4 years ago

Enviroment

JDK Version(required): 1.8

SpringBoot Version(required): 1.5.21.RELEASE

dynamic-datasource-spring-boot-starter Version(required): 3.0.0 (or any other version)

druid Version(optional): 1.1.13

Describe

execute sql error, when my postgresql with below part:

SELECT ..., TO_CHAR(lasttime, 'yyyy-mm-dd') >= TO_CHAR(CURRENT_DATE AT TIME ZONE 'utc' - INTERVAL '${offsetDays - 1}' DAY, 'yyyy-mm-dd') AS isAdded,

It seems to be not available when many key words appeared in a selected column. When I comment dependency 'dynamic-datasource-spring-boot-starter', the sql works well.

Expected Result: execute sql success

Actual Result:
java.sql.SQLException: sql injection violation, syntax error: syntax error, expect RPAREN, actual IDENTIFIER pos 238, line 5, column 73, token IDENTIFIER AT

Steps to reproduce

huayanYu commented 4 years ago

只负责数据源的切换,底层执行报错不管。

oulaly commented 4 years ago

只负责数据源的切换,底层执行报错不管。

@huayanYu 我在pom中去掉它这个依赖就能正常运行,引入就报错,它影响了mybatis的sql注入生成