def _concat_batched_result(batched_result, ret_fds):
    """
    Gets results of batched execution and format it to appropriate request answer
    :param batched_result: Batched result
    :param ret_fds: Descriptors of fields to return.
    :return: ReturningQuerySet if returning is not None or updated/inserted records count otherwise
    """
    if ret_fds is None:
        return sum(batched_result)
    elif len(batched_result) == 0:
        from django_pg_returning import ReturningQuerySet
        return ReturningQuerySet(None)
    else:
        from django_pg_returning import ReturningQuerySet
        return sum(batched_result[1:], batched_result[0])
