Doesn't this usually happen if q.id contains NULL. That is as per ANSI standard.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных