[web-devel] Persistent restriction on nullable fields in unique keys - is it necessary?

Michael Snoyman michael at snoyman.com
Sun Oct 24 11:03:35 CEST 2010

It's because the SQL servers can do funny things with regard to null
fields and uniqueness. If I'm not mistaken, SQLite and PostgreSQL have
different behavior: one considers to NULL rows to be the same, and one
considers them to be different. The restriction in persistent is to
prevent people from shooting themselves in the foot. I've wished the
restriction wasn't there a few times, but the alternative (having
strange SQL error messages) is even worse.

When I've *really* needed this feature, I've created a newtype wrapper
that represents Nothing as an empty string, that way I don't need to
worry about SQL's funny definition of NULL.


On Sun, Oct 24, 2010 at 10:59 AM, Max Cantor <mxcantor at gmail.com> wrote:
> Is it strictly necessary to have the restriction on nullable fields in the Persistent library?  Since Eq a => Eq (Maybe a) it shouldn't be strictly necessary right?
> I haven't looked at the underlying code yet, just curious..
> Max
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel

More information about the web-devel mailing list