Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Postgres NULL values in unique index #167

Open Jaymon opened 1 year ago

Jaymon commented 1 year ago

Looks like Postgres 15 has a new thing where you can set UNIQUE NULLS NOT DISTINCT so that NULL values aren't treated as always different. Would I want to support something like this?

Here is how they behave when this isn't used:

In general, a unique constraint is violated if there is more than one row in the table where the values of all of the columns included in the constraint are equal. However, two null values are never considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior conforms to the SQL standard, but we have heard that other SQL databases might not follow this rule. So be careful when developing applications that are intended to be portable.

search: