[PATCH] parser: Use 'objects.create' instead of 'save'
Daniel Axtens
dja at axtens.net
Wed Oct 31 10:33:24 AEDT 2018
Acked-by: Daniel Axtens <dja at axtens.net>
Stephen Finucane <stephen at that.guru> writes:
> As noted in the Django documentation [1], this lets us do things in one
> step.
>
> [1] https://docs.djangoproject.com/en/dev/topics/db/queries/#creating-objects
>
> Signed-off-by: Stephen Finucane <stephen at that.guru>
> ---
> patchwork/parser.py | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 6b7189cb..d6fa8437 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -1034,12 +1034,12 @@ def parse_mail(mail, list_id=None):
> # - there is an existing series, but it already has a patch with this
> # number in it
> if not series or Patch.objects.filter(series=series, number=x).count():
> - series = Series(project=project,
> - date=date,
> - submitter=author,
> - version=version,
> - total=n)
> - series.save()
> + series = Series.objects.create(
> + project=project,
> + date=date,
> + submitter=author,
> + version=version,
> + total=n)
>
> # NOTE(stephenfin) We must save references for series. We
> # do this to handle the case where a later patch is
> @@ -1109,12 +1109,12 @@ def parse_mail(mail, list_id=None):
> msgid=msgid, series__project=project).first().series
>
> if not series:
> - series = Series(project=project,
> - date=date,
> - submitter=author,
> - version=version,
> - total=n)
> - series.save()
> + series = Series.objects.create(
> + project=project,
> + date=date,
> + submitter=author,
> + version=version,
> + total=n)
>
> # we don't save the in-reply-to or references fields
> # for a cover letter, as they can't refer to the same
> --
> 2.19.1
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
More information about the Patchwork
mailing list