Fix query api for custom primary key name.

Fixes #142