bug fix: update relations of a model could raise TypeErrors