Skip to content

Commit 86dec09

Browse files
network-scriptsKani999
authored andcommitted
Mirror disjoint-queryset guard in typed-tab field discovery
1 parent 69ea1cd commit 86dec09

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

netbox_custom_objects_tab/views/typed.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,21 @@ def register_typed_tabs(model_classes, weight):
418418
]
419419

420420
# Non-polymorphic fields: single related_object_type FK.
421+
# is_polymorphic=False keeps this queryset disjoint from poly_fields
422+
# below — a field row with both attrs set (legacy misconfig:
423+
# is_polymorphic is immutable upstream but related_object_type isn't
424+
# nulled when toggled) would otherwise hit both querysets. _record's
425+
# seen_field_keys stays as defence in depth.
421426
non_poly_fields = list(
422427
CustomObjectTypeField.objects.filter(
428+
is_polymorphic=False,
423429
type__in=type_choices,
424430
).select_related("custom_object_type")
425431
)
426432

427433
# Polymorphic fields: related_object_types M2M (one field → many target CTs).
428434
# Fetched as a separate queryset so we can iterate prefetched M2M targets
429-
# without an extra query per field. Both lists may overlap by PK only if
430-
# a field has both attrs set — that's a misconfiguration; we de-dup below.
435+
# without an extra query per field.
431436
poly_fields = list(
432437
CustomObjectTypeField.objects.filter(
433438
is_polymorphic=True,

0 commit comments

Comments
 (0)