Fix incorrect IDO queries.

Fixes #5088