Fix roles query

This fixes #10437.
Merge pull request #10499 from makinacorpus/pgsql

Fix roles query