* needs_docs: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31646#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: 1 => 0
* resolution: => wontfix
* needs_tests: 1 => 0
* easy: 1 => 0
Comment:
`CheckConstraint` accepts any boolean expression since Django 3.1+ so this
particular one can be expressed using `RawSQL`
{{{#!python
CheckConstraint(
check=RawSQL(
'non_null_count(amount::integer , amount_off::integer,
percentage::integer) = 1',
output_field=models.BooleanField(),
)
)
}}}
Or event `Func`, `Cast`, and `Exact`.
{{{#!python
non_null_count = Func(Cast('amount', models.IntegerField()),
Cast('amount_off', models.IntegerField()), Cast('percentage',
models.IntegerField()), function='non_null_count')
CheckConstraint(
check=Exact(non_null_count, 1),
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31646#comment:2>