问题:
在spring项目中mapper 里的sql 语句无法执行
在Navicat中可以运行,一些关键字会被认为错误
### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:
net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "if" "IF"
at line 3, column 9.
Was expecting one of:
"*"
"+"
"-"
"?"
"@"
"@@"
"ACTION"
"ANY"
"BYTE"
"CASCADE"
"CASE"
"CAST"
"CHAR"
"COLUMN"
"COLUMNS"
"COMMENT"
"COMMIT"
"DO"
"ENABLE"
"END"
"EXTRACT"
"FIRST"
"FOLLOWING"
"GROUP_CONCAT"
"INDEX"
"INSERT"
"INTERVAL"
"ISNULL"
"KEY"
"LAST"
"MATERIALIZED"
"NO"
"NULL"
"NULLS"
"OPEN"
"OVER"
"PARTITION"
"PERCENT"
"PRECISION"
"PRIMARY"
"PRIOR"
"RANGE"
"REPLACE"
"ROW"
"ROWS"
"SEPARATOR"
"SIBLINGS"
"TABLE"
"TEMP"
"TEMPORARY"
"TRUNCATE"
"TYPE"
"UNSIGNED"
"VALUE"
"VALUES"
"XML"
"ZONE"
"{d"
"{t"
"{ts"
"~"
项目使用了 Mybatis-Plus
项目中有用到多租户的功能,Mybatis-plus 会 进行数据权限的过滤
对这一条sql 进行权限放行
Mybatis-Plus3.11版本以上 在mapper上加注解即可
@SqlParser(filter=true)
3.10及以下版本 还需要在配置中添加
mybatis-plus:
global-config:
sql-parser-cache: true