In order to fix #10421 I need to enable merge to take an option
so that relations could be merged without making the last where
condition to win.
That fix would forever reside in 4-0-stable branch and would not be
merged to master since using scope without lambda has been deprecated.
In this commit I have extracted code into a method and I think it
makes code look better. Hence the request to merge it in both
master and 4-0-stable.
If there is any concern then this code can be merged only in
4-0-stable and that would be fine too.
If `@post.comments.approved_only_without_lambda.count` is invoked
then the result is equivalent to calling
This is because when `scope` is defined without lambda then `scope`
stores an already built relation.
`@post.comments.approved_only_without_lambda` invokes the method
`scoping` changes the `current_scope` so that the relation that is
to built can make use of the `current_scope`.
However if `scope` is defined without lambda then the relation is
already built and I could not find anyway to apply current_scope
on an already built relation.
If I use `merge` then last where condition wins and that was removing
conditions from `current_scope`.
Hence I added a way to merge two relations without anyone clobbering