The following CheckConstraint is supposed to guarantee that keywords are neither null nor the empty string. Instead it checks wether at least one of these conditions is true, which is always the case.
|
models.CheckConstraint( |
|
condition=~Q(keyword="") | ~Q(keyword__isnull=True), |
|
name="%(app_label)s_%(class)s_non_empty_keywords", |
|
) |
The correct constraint would look like this:
models.CheckConstraint(
condition=~Q(keyword="") & Q(keyword__isnull=False),
name="%(app_label)s_%(class)s_non_empty_keywords",
)
I propose also checking that strings contain at least one non-whitespace character:
models.CheckConstraint(
condition=Q(keyword__regex=r"\S") & Q(keyword__isnull=False),
name="%(app_label)s_%(class)s_non_empty_keywords",
)
The current codebase doesn't sanitize keywords. Changing this right now would fail at least one test (tests.django.registry.tasks.tests_service.BuildOgcServiceTaskTest.test_success_with_collect_metadata_true) and prevent services with empty keywords from being registered.
The following CheckConstraint is supposed to guarantee that keywords are neither null nor the empty string. Instead it checks wether at least one of these conditions is true, which is always the case.
mrmap/backend/registry/models/metadata.py
Lines 454 to 457 in a16b3ac
The correct constraint would look like this:
I propose also checking that strings contain at least one non-whitespace character:
The current codebase doesn't sanitize keywords. Changing this right now would fail at least one test (tests.django.registry.tasks.tests_service.BuildOgcServiceTaskTest.test_success_with_collect_metadata_true) and prevent services with empty keywords from being registered.