Skip to content

JADE中##sql拼接问题 #39

@xugege

Description

@xugege

现象
当SQL中使用##拼接sql字符串时,如果sql语句中使用了in的sql语法,就会导致解析错误

查看源码
ReplacementIntercepter中的##解析的正则表达式有问题
final Pattern PATTERN = Pattern.compile("\{([a-zA-Z0-9_\.\:]+)\}|##\((.+)\)");
这个正则表达式采用的是贪婪模式
如下sql
update ##(:1) set status=:2 where id in (:3)

源码
while (matcher.find(start)) {
String group = matcher.group();
String key = null;
if (group.startsWith("{")) {
key = matcher.group(1);
} else if (group.startsWith("##(")) {
key = matcher.group(2); //key = :1) set status=:2 where id in (:3
}

Activity

xuemengchaojiushiwo

xuemengchaojiushiwo commented on Jul 12, 2018

@xuemengchaojiushiwo

我也发现这个问题了,有什么可以变通的方法吗?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xugege@xuemengchaojiushiwo

        Issue actions

          JADE中##sql拼接问题 · Issue #39 · paoding-code/paoding-rose