Fix primary key detection.