Given a GroupJoin query like:
We get this QueryModel:
Note the highlighted QSRE, which does not correspond to the outer query source ([c]) but rather the sub-query of the main from clause.
I've analyzed this issue and the problem is that GroupJoinExpressionNode instantiates a helper JoinExpressionNode in it's constructor, passing in the current source expression node to that helper JoinExpressionNode. Later, when the QueryModel is built using Apply, a subquery is introduced and the source is changed to a new MainExpressionNode holding that subquery (due to the Take), but the JoinExpessionNode doesn't see this new source.
I've pushed a spike fix to the internal Git repository, see 28d38fbb9a536d0295fc1f3d1249356d6c34a421 (spike/RMLNQ-105-Possible-Fix) - please check it out.
In the long run, the mutation performed by MethodCallExpressionNodeBase.WrapQueryModel should probably be replaced by a more stable mechanism - it's just too easy to introduce a bug by relying on the source node being parsed into the ctor.
Thanks for the solution!
For backwards compatibility we will also be needing (the option object, will be passed into MethodCallExpressionParseInfo) to allow for explicit enabling of this bugfix.
This property will also be affected by the bugfix since it returns the QuerySource value as it was during initialization of the ExpressionNode. The probably least-breaking update to this would be to leave this behavior as-is, but add an ObsoleteAttribte notifying the user of this discrepancy in the behavior. By going this route, we don't need the options-object for this bugfix.