Skip to content

Commit

Permalink
[#4396] Fixed wrong constraints in FormVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
vaszig committed Sep 27, 2024
1 parent 23c19f7 commit b650c69
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.16 on 2024-09-26 15:03
# Generated by Django 4.2.16 on 2024-09-27 10:38

from django.db import migrations, models

Expand Down Expand Up @@ -28,29 +28,29 @@ class Migration(migrations.Migration):
models.Q(
("prefill_plugin", ""),
("prefill_attribute", ""),
("prefill_options__isnull", True),
("prefill_options", {}),
),
models.Q(
models.Q(("prefill_plugin", ""), _negated=True),
models.Q(("prefill_attribute", ""), _negated=True),
("prefill_options__isnull", True),
("prefill_options", {}),
),
models.Q(
models.Q(("prefill_plugin", ""), _negated=True),
("prefill_attribute", ""),
("prefill_options__isnull", False),
models.Q(("prefill_options", {}), _negated=True),
),
models.Q(
models.Q(
("prefill_plugin", ""),
("prefill_attribute", ""),
("prefill_options__isnull", False),
models.Q(("prefill_options", {}), _negated=True),
_negated=True,
),
models.Q(
models.Q(("prefill_plugin", ""), _negated=True),
models.Q(("prefill_attribute", ""), _negated=True),
("prefill_options__isnull", False),
models.Q(("prefill_options", {}), _negated=True),
_negated=True,
),
),
Expand Down
35 changes: 20 additions & 15 deletions src/openforms/forms/models/form_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
from .form_step import FormStep


EMPTY_PREFILL_PLUGIN = Q(prefill_plugin="")
EMPTY_PREFILL_ATTRIBUTE = Q(prefill_attribute="")
EMPTY_PREFILL_OPTIONS = Q(prefill_options={})


class FormVariableManager(models.Manager):
use_in_migrations = True

Expand Down Expand Up @@ -203,29 +208,29 @@ class Meta:
CheckConstraint(
check=(
(
Q(prefill_plugin="")
& Q(prefill_attribute="")
& Q(prefill_options__isnull=True)
EMPTY_PREFILL_PLUGIN
& EMPTY_PREFILL_ATTRIBUTE
& EMPTY_PREFILL_OPTIONS
)
| (
~Q(prefill_plugin="")
& ~Q(prefill_attribute="")
& Q(prefill_options__isnull=True)
~EMPTY_PREFILL_PLUGIN
& ~EMPTY_PREFILL_ATTRIBUTE
& EMPTY_PREFILL_OPTIONS
)
| (
~Q(prefill_plugin="")
& Q(prefill_attribute="")
& Q(prefill_options__isnull=False)
~EMPTY_PREFILL_PLUGIN
& EMPTY_PREFILL_ATTRIBUTE
& ~EMPTY_PREFILL_OPTIONS
)
| ~(
Q(prefill_plugin="")
& Q(prefill_attribute="")
& Q(prefill_options__isnull=False)
EMPTY_PREFILL_PLUGIN
& EMPTY_PREFILL_ATTRIBUTE
& ~EMPTY_PREFILL_OPTIONS
)
& ~(
~Q(prefill_plugin="")
& ~Q(prefill_attribute="")
& Q(prefill_options__isnull=False)
~EMPTY_PREFILL_PLUGIN
& ~EMPTY_PREFILL_ATTRIBUTE
& ~EMPTY_PREFILL_OPTIONS
)
),
name="prefill_config_component_or_user_defined",
Expand Down

0 comments on commit b650c69

Please sign in to comment.