﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36594	UniqueConstraint with a boolean value of nulls_distinct causes misleading warning for sqlite (and likely other dbs)	Russell Owen		"I was trying to create a UniqueConstraint with `nulls_distinct=False` using sqlite. When I migrated my sqlite database I got this warning:
{{{
SQLite does not support unique constraints with nulls distinct.
}}}
That message implies that the value of False should work, so it is misleading.

It turns out that boolean values of nulls_distinct are only acceptable for postgresql, which I missed when I first read the docs. It would be very helpful if the warning message included the information that boolean values of nulls_distinct are not acceptable for sqlite (or whatever database is triggering the warning) so the user knows how to fix the problem.

Having the warning also include the information about the actual behavior is a nice touch, but is not the heart of the problem.

Here is the simplest model I could come up with that shows the issue:
{{{
class SimpleModel(models.Model):
    field_a = models.IntegerField(null=True)
    field_b = models.IntegerField(null=True)

    class Meta:
        constraints = [
            UniqueConstraint(
                name=""simple_unique_constraint"",
                fields=[""field_a"", ""field_b""],
                nulls_distinct=False,
            ),
        ]
}}}
(The same warning is printed whether nulls_distinct is False or True, which is why it is so confusing.)

It would be also nice to emphasize the limitation of `nulls_distinct` in the documentation by making it warning or putting it in bold as the first line of the description of the argument."	Uncategorized	new	Database layer (models, ORM)	5.2	Normal		UniqueConstraint nulls_distinct		Unreviewed	0	0	0	0	0	0
