Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Again, you can call CCJSqlParserUtil.sanitizeSingleSql( sqlStr) to clean your statements properly. #6187

Open
nieqiurong opened this issue May 21, 2024 · 5 comments

Comments

@nieqiurong
Copy link
Contributor

          Again, you can call `CCJSqlParserUtil.sanitizeSingleSql( sqlStr)` to clean your statements properly.

Details see here: JSQLParser/JSqlParser#1988 (comment)

Originally posted by @manticore-projects in #5345 (comment)

@lujiamingzZ
Copy link

lujiamingzZ commented May 27, 2024

为何不是官方在BoundSql的统一生成处使用CCJSqlParserUtil.sanitizeSingleSql来处理呢?直接从源头处理掉是不是会更好;像DataPermissionInterceptor中beforeQuery、beforePrepare的方法中会调用parserSingle和parserMulti方法,这里面会走校验,那在调用之前先CCJSqlParserUtil.sanitizeSingleSql处理一下或者在更早的地方处理应该更好一些吧?
@nieqiurong

@nieqiurong
Copy link
Contributor Author

统计3.5.3.2后面版本框架提供的方法出现情况.

@nieqiurong nieqiurong pinned this issue Jul 12, 2024
@rowstop
Copy link
Contributor

rowstop commented Oct 17, 2024

Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT
xxxx
         WHERE deleted=0


            
                
                AND coupon.shop_id != 0 
        ORDER BY coupon.create_time DESC
        at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:39)
        at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.parserSingle(JsqlParserSupport.java:51)
        at com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor.beforeQuery(TenantLineInnerInterceptor.java:70)
        at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:78)
        at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
        at jdk.proxy2/jdk.proxy2.$Proxy431.query(Unknown Source)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154)
        ... 203 common frames omitted
Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "AND" "AND"
    at line 30, column 17.

Was expecting:

    <EOF>

        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:205)
        at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:343)
        at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:123)
        at com.baomidou.mybatisplus.extension.parser.JsqlParserGlobal.lambda$static$1(JsqlParserGlobal.java:58)
        at com.baomidou.mybatisplus.extension.parser.JsqlParserGlobal.parse(JsqlParserGlobal.java:68)
        at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.parserSingle(JsqlParserSupport.java:48)
        ... 208 common frames omitted
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "AND" "AND"
    at line 30, column 17.

Was expecting:

    <EOF>

        at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:39603)
        at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:39427)
        at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:317)
        at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:339)
        at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:336)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        ... 1 common frames omitted

@laihaibing
Copy link

jsqlparser4.9版本 没有找到这个方法 :CCJSqlParserUtil.sanitizeSingleSql

@oddity123
Copy link

在使用DataPermissionInterceptor后就出现了这个问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants