Prevent failure in case no record is found (empty database) (fixes #1363)
Merge branch 'bug-1363-error-500-api-empty-database' into integration