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

Support OR #501

Closed
wangqisen opened this issue Dec 20, 2017 · 9 comments
Closed

Support OR #501

wangqisen opened this issue Dec 20, 2017 · 9 comments
Assignees

Comments

@wangqisen
Copy link

wangqisen commented Dec 20, 2017

Please answer these questions before submitting your issue. Thanks!

Which version of Sharding-Jdbc do you using?

1.5.0

Expected behavior

期望支持OR语句

Actual behavior

不支持OR语句

Steps to reproduce the behavior

Please provide the reproduce example codes (such as github link) if possible.

@wangqisen
Copy link
Author

正在完成新增OR语句的工作,deadline:2018/01/30

@terrymanu
Copy link
Member

👍 关注中

@haocao
Copy link
Member

haocao commented Dec 29, 2017

感谢为sharding-jdbc提供代码,以下是我们这边测试的结果:
对于SQL:

SELECT * FROM t_order WHERE user_id =OR order_id =

user_id是10,order_id是1000,生成结果为:

[INFO ] 13:14:39.831 [main] Sharding-JDBC-SQL - Logic SQL: SELECT * FROM t_order WHERE user_id = ? OR order_id = ?
[INFO ] 13:14:39.834 [main] Sharding-JDBC-SQL - Actual SQL: dataSource_tbl ::: SELECT * FROM t_order_0 WHERE user_id = ? OR order_id = ? ::: [10, 1000]

我们预期的结果应该是对多个分表查询,而目前仅对t_order_0表进行了查询,这块逻辑有点儿问题,还需要再完善一下。

@wangqisen
Copy link
Author

wangqisen commented Jan 3, 2018

@haocao 谢谢测试和review!我刚重新跑了下单测OrShardingPreparedStatementTest中的assertExecuteQueryWithParameter()测试用例,发现可以对于SQL:
SELECT * FROM t_order WHERE user_id = ? OR order_id = ?
进行全部分表的查询。

结果如下:
[INFO] 12:01:37.932 [main] Sharding-JDBC-SQL - Logic SQL: SELECT * FROM t_order WHERE user_id= ? OR order_id = ?
[INFO ] 12:01:37.950 [main] Sharding-JDBC-SQL - Actual SQL: dataSource_jdbc_1 ::: SELECT * FROM t_order_0 WHERE user_id= ? OR order_id = ? ::: [10, 1000]
[INFO ] 12:01:37.950 [main] Sharding-JDBC-SQL - Actual SQL: dataSource_jdbc_1 ::: SELECT * FROM t_order_1 WHERE user_id= ? OR order_id = ? ::: [10, 1000]
[INFO ] 12:01:37.950 [main] Sharding-JDBC-SQL - Actual SQL: dataSource_jdbc_0 ::: SELECT * FROM t_order_0 WHERE user_id= ? OR order_id = ? ::: [10, 1000]
[INFO ] 12:01:37.950 [main] Sharding-JDBC-SQL - Actual SQL: dataSource_jdbc_0 ::: SELECT * FROM t_order_1 WHERE user_id= ? OR order_id = ? ::: [10, 1000]

能麻烦告诉我,不能多表查询的情况是什么配置吗?

@haocao
Copy link
Member

haocao commented Jan 3, 2018

用仅分表的配置就可以复现,我写了测试用例放到你的分支上了,请查看。

@lxhuang0903
Copy link

问下现在支持or了吗 @wangqisen

@mafanchen
Copy link

@wangqisen 预计什么时候能正式支持OR语句?关注中...

@terrymanu
Copy link
Member

terrymanu commented Apr 18, 2018

fixed at 3.0.0.M1

@Springs-wu
Copy link

现在支持了吗

@apache apache locked and limited conversation to collaborators Dec 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants
@haocao @wangqisen @lxhuang0903 @terrymanu @maxiaoguang64 @Springs-wu @mafanchen and others