Fixed a primary key assigning bug