Database: fixed work with undefined primary key [Refs #288]