Database: fixed refetching rows, refecth query contains primary keys [closes #1045]