Fixing bug when caching a unique row in ORM