Fix roles query

This fixes #10437.