fix problem for empty database

cc @toto