fix primary keys handling