Skip to content

Commit 8657a92

Browse files
committed
Update Patch constraint to handel empty and null case
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 4dd81f3 commit 8657a92

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

vulnerabilities/migrations/0104_packagecommitpatch_patch_and_more.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.25 on 2025-12-11 11:10
1+
# Generated by Django 4.2.25 on 2025-12-11 12:23
22

33
from django.db import migrations, models
44

@@ -101,7 +101,10 @@ class Migration(migrations.Migration):
101101
model_name="patch",
102102
constraint=models.CheckConstraint(
103103
check=models.Q(
104-
("patch_url__isnull", False), ("patch_text__isnull", False), _connector="OR"
104+
models.Q(
105+
("patch_url__isnull", False), ("patch_text__isnull", False), _connector="OR"
106+
),
107+
models.Q(("patch_url", ""), ("patch_text", ""), _negated=True),
105108
),
106109
name="patch_url_or_patch_text",
107110
),

vulnerabilities/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2782,7 +2782,8 @@ class Meta:
27822782
unique_together = ["patch_checksum", "patch_url"]
27832783
constraints = [
27842784
models.CheckConstraint(
2785-
check=(Q(patch_url__isnull=False) | Q(patch_text__isnull=False)),
2785+
check=(Q(patch_url__isnull=False) | Q(patch_text__isnull=False))
2786+
& ~(Q(patch_url="") & Q(patch_text="")),
27862787
name="patch_url_or_patch_text",
27872788
)
27882789
]

0 commit comments

Comments
 (0)