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

SQLASTOutputVisitor类中参数parameterizedMergeInList=false时,解析出来的问号个数和参数值个数不对应 #1737

Closed
qxo opened this issue May 15, 2017 · 2 comments
Labels
Milestone

Comments

@qxo
Copy link
Contributor

qxo commented May 15, 2017

visit(SQLInListExpr x)方法目前有一代码段如下:

 if (parameterizedMergeInList) {
                        List<Object> subList = new ArrayList<Object>(x.getTargetList().size());
                        for (SQLExpr target : x.getTargetList()) {
                            ExportParameterVisitorUtils.exportParameter(subList, target);
                        }
                        if (subList != null) {
                            parameters.add(subList);
                        }
                    } else {
                        for (SQLExpr target : x.getTargetList()) {
                            ExportParameterVisitorUtils.exportParameter(this.parameters, target);
                        }
                    }

当前parameterizedMergeInList默认为false,会导致解析出来的,sql中的问号个数和参数值个数不对应哦!

以下的测试代码

  String sql = "select * from test_tab1 where name='name' and id in  ('A','B')";
       final StringBuilder out = new StringBuilder();
       final ExportParameterVisitor visitor = new OracleExportParameterVisitor(out);
       // visitor.setParameterizedMergeInList(true);
        SQLStatementParser parser = new OracleStatementParser(sql);
        final SQLStatement parseStatement = parser.parseStatement();
        parseStatement.accept(visitor);
        final List<Object> plist = visitor.getParameters();
        sql = out.toString();
        System.out.println("src:"+sql);
        System.out.println("sql:"+sql+" params:"+plist);
@wenshao wenshao added this to the 1.0.32 milestone May 15, 2017
@wenshao wenshao added the Bug label May 15, 2017
@qxo qxo changed the title SQLASTOutputVisitor类中参数parameterizedMergeInList的要么默认值应true, 要么对应逻辑搞反了 SQLASTOutputVisitor类中参数parameterizedMergeInList=false时,解析出来的问号个数和参数值个数不对应 May 15, 2017
@wenshao wenshao modified the milestones: 1.1.0, 1.0.32 Jun 25, 2017
@wenshao
Copy link
Member

wenshao commented Jun 25, 2017

没问题哈,默认值是false

@wenshao
Copy link
Member

wenshao commented Jun 25, 2017

已修复问题,请用新版本 https://github.com/alibaba/druid/releases/tag/1.1.0

@wenshao wenshao closed this as completed Jun 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants