Skip to content

Commit

Permalink
Avoid an extra exists() query
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Nov 6, 2024
1 parent b68ec6f commit 4f26c7f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions arches/app/models/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,14 +2302,10 @@ def validate_fieldname(fieldname, fieldnames):
.filter(slug=self.slug)
)
if (
graphs_with_matching_slug.exists()
and graphs_with_matching_slug[0].graphid != self.graphid
):
first_matching_graph := graphs_with_matching_slug.first()
) and first_matching_graph.graphid != self.graphid:
if self.source_identifier_id:
if (
self.source_identifier_id
!= graphs_with_matching_slug[0].graphid
):
if self.source_identifier_id != first_matching_graph.graphid:
raise GraphValidationError(
_(
"Another resource model already uses the slug '{self.slug}'"
Expand Down

0 comments on commit 4f26c7f

Please sign in to comment.