use $primary_key to fetch the primary key

When having tables which do not use `id` as primary key this previously caused issues.

Guess I have to add some tests for this faulty behavior though..