Fix crash on empty database