Skip to content

Fixes chained join method's signature in the QueryBuilder#252

Open
derenio wants to merge 1 commit into
greenrobot:masterfrom
derenio:fix/chained_join_signature
Open

Fixes chained join method's signature in the QueryBuilder#252
derenio wants to merge 1 commit into
greenrobot:masterfrom
derenio:fix/chained_join_signature

Conversation

@derenio

@derenio derenio commented Oct 26, 2015

Copy link
Copy Markdown

No description provided.

@jeffdgr8

Copy link
Copy Markdown

@greenrobot @greenrobot-team can this fix be looked at merging? Anyone that's doing chained joins has to be casting the sourceJoin argument here to the incorrect Join<?, T> in order for the method to accept the argument. Your own chained join sample won't compile with the code as is.

Part of the problem is that the return type of the method actually isn't Join<T, J>, but rather Join<J, K>, as the QueryBuilder's T is not the intended type of the chained join, rather it's joining to a new K type, from the J type of the previous join. The method signature would be more appropriate as:

public <J, K> Join<J, K> join(Join<?, J> sourceJoin, Property sourceProperty, Class<K> destinationEntityClass, Property destinationProperty)

And addJoin() would more correctly be:

private <J> Join<?, J> addJoin(String sourceTablePrefix, Property sourceProperty, AbstractDao<J, ?> destinationDao, Property destinationProperty)

as the join may be from T in the non-chained join() methods or it may be from a chained type from the chained join() method.

@jeffdgr8

Copy link
Copy Markdown

I created a pull request with the fix I described above: #913.

This pull request fix will work, but the type of the Join generics are still incorrect, which although they're not actually used, can be misleading.

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

Successfully merging this pull request may close these issues.

2 participants