feat(tags): add unique constraint to value and implement __str__#898
feat(tags): add unique constraint to value and implement __str__#898DarshanCode2005 wants to merge 2 commits intoNixOS:mainfrom
Conversation
|
This is one of the many things we can't "just do". At the very least it would require a migration to actually deduplicate the existing data, and a change in the ingestion code to do get_or_create. But what we just the other day happened to discuss with @adekoder is that we probably want to inline that extra table into the one field that references it. There's no use case currently in sight that would benefit from a separate table, and the amount of duplication an ArrayField would incur is negligible in the grand scheme of things. |
|
Thanks for the detailed explanation, that makes sense. I agree that adding unique=True would require a data migration and is not a small change anymore. I will remove that from this PR and keep it focused on the str improvement. We can revisit uniqueness and possible schema simplification in a separate discussion/PR. |
|
|
||
| value = models.CharField(max_length=128) | ||
|
|
||
| def __str__(self) -> str: |
There was a problem hiding this comment.
Now, were we doing that by hand anywhere in the code? If so, please use this new thing there, if not, we can close the PR. :)
|
code snippet: so there we can use str(tag). |
Or just |
Hmm.... I actually wrote that by mistake. |
This PR improves data integrity and observability for the
Tagmodel.Changes:
src/shared/models/cve.py:strto return the tag's value, improving the representation in logs.Rationale: Duplicate tags ("critical", "critical" etc.) were previously possible in the database, leading to inconsistent data. This change enforces a clean tag registry. The string representation also significantly improves the developer & admin experience by making objects identifiable by their actual text.