Fix bug which throws an Exception when query is called with an exisiting row