valderman / selda

A type-safe, high-level SQL library for Haskell
https://selda.link
MIT License
478 stars 58 forks source link

Add support for PostgreSQL citext type provided by citext extension #132

Closed alexmingoia closed 4 years ago

alexmingoia commented 4 years ago

The citext extension is a popular extension for supporting case-insensitive column types, so that unique constraints and other comparisons are case-insensitive. This extension is supported by most managed PostgreSQL hosting services (AWS, Heroku, etc.).


Thank you @valderman for this amazing library! ❤️

valderman commented 4 years ago

This would be nice to have, but I'm a little bit uneasy about something like someCol .== "foo" silenty behaving differently depending on the type of the underlying column. Especially when this will not work with the validation and migration functionality.

Would it not be better to add support for this as a separate type, perhaps mapping to either CI Text, or a custom CI type to avoid pulling in all the dependencies of semigroups?

alexmingoia commented 4 years ago

Good points. I think the deeper problem here is extensibility and the lack of an interface for custom type encoding, and I’m not familiar enough with Selda yet to propose a solution. It doesn’t seem practical to keep adding SQL types to support different extensions.

For example, let’s say one wanted to write a library that adds PostGIS (very common) support to Selda. It seems one would need a way to define new type encodings and comparison functions for queries (like ST_Intersects or other functions provided by extensions).

Anyways. I will close this PR and open some related issues when I have given this more thought and after I’ve familiarized myself with Selda’s internals.