if query finds no row in the database, create a new one instead

fixes regression introduced in fc9ada9b44478d5638d07f1090fda6d7b0c5e771