[PR #17814] [MERGED] Closes #17761: Store empty CharField choices as null #15206

Closed
opened 2025-12-30 00:20:37 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17814
Author: @jeremystretch
Created: 10/18/2024
Status: Merged
Merged: 10/21/2024
Merged by: @jeremystretch

Base: featureHead: 17761-null-CharFields


📝 Commits (1)

📊 Changes

23 files changed (+622 additions, -25 deletions)

View changed files

netbox/circuits/migrations/0046_charfield_null_choices.py (+43 -0)
📝 netbox/circuits/models/circuits.py (+2 -1)
netbox/dcim/migrations/0194_charfield_null_choices.py (+287 -0)
📝 netbox/dcim/models/cables.py (+5 -3)
📝 netbox/dcim/models/device_component_templates.py (+12 -4)
📝 netbox/dcim/models/device_components.py (+12 -1)
📝 netbox/dcim/models/devices.py (+8 -3)
📝 netbox/dcim/models/racks.py (+7 -4)
📝 netbox/dcim/tests/test_filtersets.py (+0 -1)
📝 netbox/dcim/tests/test_views.py (+1 -1)
netbox/extras/migrations/0122_charfield_null_choices.py (+29 -0)
📝 netbox/extras/models/customfields.py (+1 -0)
netbox/ipam/migrations/0073_charfield_null_choices.py (+36 -0)
📝 netbox/ipam/models/fhrp.py (+1 -0)
📝 netbox/ipam/models/ip.py (+1 -0)
📝 netbox/netbox/models/mixins.py (+3 -1)
netbox/tenancy/migrations/0016_charfield_null_choices.py (+29 -0)
📝 netbox/tenancy/models/contacts.py (+2 -1)
netbox/virtualization/migrations/0041_charfield_null_choices.py (+29 -0)
netbox/vpn/migrations/0006_charfield_null_choices.py (+49 -0)

...and 3 more files

📄 Description

Fixes: #17761

  • Add null=True to all optional CharFields with choices set
  • Automatically update all empty string values with null during migration
  • Miscellaneous cleanup inside models to avoid writing empty string values

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/17814 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 10/18/2024 **Status:** ✅ Merged **Merged:** 10/21/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `17761-null-CharFields` --- ### 📝 Commits (1) - [`d06681a`](https://github.com/netbox-community/netbox/commit/d06681a5e2d13e4aefc7a6d8310b94b584d8f9b2) Closes #17761: Store empty CharField choices as null ### 📊 Changes **23 files changed** (+622 additions, -25 deletions) <details> <summary>View changed files</summary> ➕ `netbox/circuits/migrations/0046_charfield_null_choices.py` (+43 -0) 📝 `netbox/circuits/models/circuits.py` (+2 -1) ➕ `netbox/dcim/migrations/0194_charfield_null_choices.py` (+287 -0) 📝 `netbox/dcim/models/cables.py` (+5 -3) 📝 `netbox/dcim/models/device_component_templates.py` (+12 -4) 📝 `netbox/dcim/models/device_components.py` (+12 -1) 📝 `netbox/dcim/models/devices.py` (+8 -3) 📝 `netbox/dcim/models/racks.py` (+7 -4) 📝 `netbox/dcim/tests/test_filtersets.py` (+0 -1) 📝 `netbox/dcim/tests/test_views.py` (+1 -1) ➕ `netbox/extras/migrations/0122_charfield_null_choices.py` (+29 -0) 📝 `netbox/extras/models/customfields.py` (+1 -0) ➕ `netbox/ipam/migrations/0073_charfield_null_choices.py` (+36 -0) 📝 `netbox/ipam/models/fhrp.py` (+1 -0) 📝 `netbox/ipam/models/ip.py` (+1 -0) 📝 `netbox/netbox/models/mixins.py` (+3 -1) ➕ `netbox/tenancy/migrations/0016_charfield_null_choices.py` (+29 -0) 📝 `netbox/tenancy/models/contacts.py` (+2 -1) ➕ `netbox/virtualization/migrations/0041_charfield_null_choices.py` (+29 -0) ➕ `netbox/vpn/migrations/0006_charfield_null_choices.py` (+49 -0) _...and 3 more files_ </details> ### 📄 Description ### Fixes: #17761 - Add `null=True` to all optional CharFields with `choices` set - Automatically update all empty string values with null during migration - Miscellaneous cleanup inside models to avoid writing empty string values --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:20:37 +01:00
adam closed this issue 2025-12-30 00:20:37 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15206