Fix sql error in case primary key is not named "id"