Fix db_ido queries.

Fixes #6007