Sorry, this will be a bit complex but I found no easy way to reproduce.
Using the Northwind database and OA version 2015.1.225.1
// Combine the predicates by replacing pred2's parameter by pred1's and merge the bodies
The basic idea is I have an arbitrary predicate (in this case employee name="Andrew") from external code that I want to augment in a more complex query (it applies either to the employee or his manager). The important factor seems to be that pred1's body occurs in more than one place in the final expression tree, all occurences are reference-equal. I get the following query:
The problem is with the last condition, it references the wrong table. It should be
Is there any way (apart from cloning pred1's body on every use) to work around this?