Add test from #12544.

The final query fails, so needs fixing.