Closed bergmark closed 9 years ago
As a point of information 'When building from the source distribution, these components [including citext
] are not built automatically, unless you build the "world" target'. So they may be almost always available, but it doesn't seem that it can be guaranteed.
I guess you are talking about the package called case-insensitive
. I think I probably don't want to incur the extra dependency right now but I would definitely encourage the creation of an opaleye-contrib
package where we can publically provide nice new functionality for community testing.
Makes sense!
Unfortunately there isn't really a good solution for this. A contrib package would be full of orphan instances, just that by itself can get annoying for users and from a maintenance standpoint. A contrib package would also end up with lots of dependencies that you may not want. You can use flags for this, like semigroup does, but there's no good way to override these flags if you don't install the package explicitly as far as I know.
In the meantime, if someone else wants this, here it is:
instance FromField (CI Text) where
fromField f mdata = do
ty <- FF.typename f
if ty /= "citext"
then FF.returnError FF.Incompatible f ""
else maybe (FF.returnError FF.UnexpectedNull f "") (return . CI.mk) . fmap T.decodeUtf8 $ mdata
instance Default QueryRunner (Wire (CI Text)) (CI Text) where
def = fieldQueryRunner
I see. I'm more inclined to consider adding such functionality then. Feel free to reopen if this becomes pressing again.
Currently we have an instance mapping
case-insensitive
to postgrescitext
.citext
is an extension that I think is always available.Does it make sense to include these in opaleye itself or should they go in a separate package?
This particular case also introduces an extra dependency so it also depends on how "batteries included" opaleye should be.