-
Notifications
You must be signed in to change notification settings - Fork 64
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
Left vs Inner joins issue #81
Comments
Do you have any sample codes? |
for example this test
|
Can you provide the expected result and actual result? Thanks. |
expected result should be 3 users
instead of one result as of this actual query
|
Could you try this? @Test
public final void testJoinHintsRelationWithMultipleOrCase() {
String rsql = "company.code==demo,city.name=='Hong Kong Island'";
Map<String, JoinType> joinHints = new HashMap<String, JoinType>() {{put("User.city", JoinType.LEFT);put("User.company", JoinType.LEFT);}};
List<User> users = userRepository.findAll(toSpecification(rsql, true,null, joinHints));
long count = users.size();
log.info("rsql: {} -> count: {}", rsql, count);
assertThat(rsql, count, is(3l));
} |
yes, but as I said I don't find join hints meaningful. I don't know which rsql string will be send by client. |
Should we always use left join only if the relationship is optional? Otherwise, use inner join. |
unfortunately rules are not that simple. I will try to write them down |
Not 100% sure if this is all but this is what I've came up:
|
although first point is questionable I guess |
Do you have time to implement it? It would be more easy to verify with test cases. |
well, I could try, but do you have an idea how to go about that? afaik we need to determine join type based on data later during visiting. |
Could we first analyze the structure of the query and generate the JoinHint before processing in converter (RSQLVisitor)? |
hmm, that's good idea. |
I didn't find any follow-up of #39.
How should one handle this issue? I don't think that join hints are way to go, as whether to use left or right join depends on query parameters being used and whether a relationship is optional somewhere on the path.
i.e if we have
relationship1.value==abc or relationship1.value=na=''
if relationship1 is not optional, there is no point in left join.
if relationship1 is optional it should be joined left.
if relationship1 is optional but there is no "or is null" it should be inner join.
there is also usecase mentioned in last comment of linked PR.
afaiu this would need some preprocessing, cause join type can't be changed on the fly, right?
The text was updated successfully, but these errors were encountered: