Skip to content

Project: get_latest_build and prefetch use different queries #12227

@agjohnson

Description

@agjohnson

Noticed and partially fixed in #12225, these two methods can result in different queries to the list of builds:

  • Project.objects.get(pk=123).get_latest_build()
  • Project.objects.prefetch_latest_build().get(pk=123).get_latest_build()

This is because get_latest_build() uses a different query filter and takes a finished=True argument by default, however when using prefetch the query filter is different and completely discards the fishined argument.

The get_latest_build() method is not used in many places and mostly just from templates. We could either make the query match when using/not using prefetch, or just only allow this method when builds are prefetched -- throwing an exception otherwise. I didn't chase down a solution to this, I was working on an unrelated fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions