ORM query bug fix.