Add auto complete, rewrite raw sql in ORM way