Skip to content

[fix/change] Avoid depending on creation date in get_max_subnet method #728

Description

@nemesifier

In the get_max_subnet method:

@staticmethod
def get_max_subnet(master_subnet, division_rule):
try:
max_subnet = (
# Get the highest subnet created for this master_subnet
Subnet.objects.filter(master_subnet_id=master_subnet.id)
.order_by('-created')
.first()
.subnet
)

Relying on the creation date to order the subnets will not work in all cases.
Ordering by subnet will work on PostgreSQL, which is the DB we use in almost all deployments, while on SQlite it won't work, I think an acceptable solution right now is to check which DB is being used in the default database and depending on that order either by subnet or fallback on creation date. Let's check this behavior on MySQL too to ensure the solution is robust.

Metadata

Metadata

Assignees

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions