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

catFilter参数打印问题 #29

Closed
RongNanNan opened this issue Mar 4, 2019 · 8 comments
Closed

catFilter参数打印问题 #29

RongNanNan opened this issue Mar 4, 2019 · 8 comments

Comments

@RongNanNan
Copy link

catFilter打印sql参数时,List

@RongNanNan
Copy link
Author

catFilter打印sql参数时,List,是按照list的顺序打印,并不是按照真实parameterIndex的位置打的,如果set参数不是按照顺序的化,打印的有问题

@8wy1985659
Copy link
Collaborator

已修复
f2f750f

@RongNanNan
Copy link
Author

e,(?,?,?)调用:setString(3, '3')再setString(2, '2')再setString(1, '1')不会报错?

@RongNanNan
Copy link
Author

使用Set记录实现Comparable,或是提供比较器给外面
private static Comparator PARAM_COMPARATOR = new Comparator(){
@OverRide
public int compare(ParamContext paramContext1, ParamContext paramContext2) {
return paramContext1.getIndex() - paramContext2.getIndex();
}
};

@8wy1985659
Copy link
Collaborator

从使用方式上来讲 先setString(3, '3')再setString(2, '2')再setString(1, '1') 并不是必要需求
与其最后去compare 不如在插入时限定好顺序 我是这样理解的

@RongNanNan
Copy link
Author

我们的想法可能不一样,我的理解就是参数的打印顺序必须和sql里面的占位的顺序完全一致,而且没有文档标注必须按顺序进行参数设置,只要设置完全即可

另,如果不认同这个观点的话,建议还是不要修复了(交由别人的内部版本视情况修改),否则还会导致错误

@8wy1985659
Copy link
Collaborator

2种方案都可以保证打印顺序 不过开源版本确实应该考虑好兼容性 这里我同意你的观点
不过从实际使用上来讲 我确实觉得没有必要过于灵活

@ainilife
Copy link
Member

ainilife commented Mar 5, 2019

这个问题不大。按照你的这个要求去实现有点复杂,建议还是保持现状。无伤大雅。

66254264 added a commit to 66254264/Zebra that referenced this issue Mar 8, 2019
fix params ordering in pstmt in another way, fixes Meituan-Dianping#29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants