Skip to content

Convert all optional choice fields to use a null empty value #17761

Closed
@jeremystretch

Description

@jeremystretch

NetBox version

v4.1.3

Feature type

Change to existing functionality

Triage priority

N/A

Proposed functionality

Several models include optional choices fields, such as Cable.type. Most (if not all) of these store an empty value as an empty string ('') rather than null. This FR proposes:

  1. Changing the empty value of these fields to null
  2. Introducing migrations to replace all empty string values with null for these fields

The list of specific fields to be updated is TBD, but is expect to include any CharField for which choices is defined and null is False.

Use case

The use of empty strings to represent empty values for these fields deviates from other fields (e.g. integer-based fields) and complicates the logic needed to achieve complex filtering (see #17575 for an example). This change will help us standardize the behavior of the data model in general.

Database changes

All CharFields which define a set of choices will be modified to store empty values as null in the database. Migrations will be included to effect this change on existing data.

External dependencies

N/A

Metadata

Metadata

Assignees

Labels

complexity: mediumRequires a substantial but not unusual amount of effort to implementnetboxstatus: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions