116 Star 797 Fork 175

baomidou / MybatisX

 / 详情

Table/field name suggestion doesnt work after parameters

待办的
创建于  
2022-01-29 04:03

in example like this:

	select *
	from USERS
	where ACTIVE = 1
	  and USERNAME = #{userName}
	  and sysdate between nvl(START_DATE, sysdate) and nvl(END_DATE, sysdate)

field/table names suggestion work perfectly in ACTIVE section, but not in "sysdate between" section.
Literally suggestion does't work in any sql exactly after any named parameters #{...}
named parameter suggestion work in any place.

IntelliJ IDEA 2021.3.1 (Ultimate Edition)
MybatisX 1.5.2

评论 (4)

kopavel 创建了任务

make an investigation/debug.
it's false-positive in
com.baomidou.plugin.idea.mybatisx.system.contributor.SqlParamCompletionContributor:54
// 如果在#{}里面输入字符, 则阻断原生SQL提示
result.stopHere();

plugin should not go in that place.
my cursor is outside of {} bracket
it's seems, that plugin always go here after first { bracket and ignore closing one "}"

com.baomidou.plugin.idea.mybatisx.system.contributor.SqlParamCompletionContributor.shouldAddElement() method do it wrong - it's definitely just seach pattern #{ before cursor but ignore }

it should be like that

private boolean shouldAddElement(PsiFile file, int offset) {
        String text = file.getText();
        for (int i = offset - 1; i > 0; i--) {
            char c = text.charAt(i);
            if (c == '}' ){    ////////////
                return false;  //////////// here is a new one piece of code 
            }                  /////////
            if (c == '{' && (text.charAt(i - 1) == '#' || text.charAt(i - 1) == '$')) {
                return true;
            }
        }
        return false;
    }

more of that - mybatis support ${} parameters too, edit my code in comment before

Any plan to merge that fix in code?? it's wary disappointing see it not merged after half a year.

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
Java
1
https://gitee.com/baomidou/MybatisX.git
git@gitee.com:baomidou/MybatisX.git
baomidou
MybatisX
MybatisX

搜索帮助

344bd9b3 5694891 D2dac590 5694891