Skip to content

Commit

Permalink
Fix PeerEndpoint ordering for Aurora DB
Browse files Browse the repository at this point in the history
  • Loading branch information
mzbroch committed Feb 8, 2024
1 parent d26c876 commit a88d3d4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions nautobot_bgp_models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ def local_ip(self):
)

class Meta:
ordering = ["pk"]
verbose_name = "BGP Peer Endpoint"

def __str__(self):
Expand Down Expand Up @@ -553,14 +554,12 @@ class Meta:
@property
def endpoint_a(self):
"""Get the "first" endpoint associated with this Peering."""
# order_by - needed by Aurora DB, to be removed via #149
return self.endpoints.order_by("pk")[0] if self.endpoints.exists() else None
return self.endpoints.all()[0] if self.endpoints.exists() else None

@property
def endpoint_z(self):
"""Get the "second" endpoint associated with this Peering."""
# order_by - needed by Aurora DB, to be removed via #149
return self.endpoints.order_by("pk")[1] if self.endpoints.count() > 1 else None
return self.endpoints.all()[1] if self.endpoints.count() > 1 else None

def __str__(self):
"""String representation of a single Peering."""
Expand Down

0 comments on commit a88d3d4

Please sign in to comment.