Fix Database::upsert implementation error