Scratch that! It was a mistake in my client code. Sorry.
It turns out that if I add the subquery after the query is executed, it doesn’t affect the query result.
Once I fixed that issue, it produced the expected output.