lpsmith / postgresql-simple

Mid-level client library for accessing PostgreSQL from Haskell
Other
206 stars 71 forks source link

make automatic execution of SET commands right after connect optional #216

Open dimsmol opened 7 years ago

dimsmol commented 7 years ago

connectPostgreSQL executes several SET commands automatically right after connecting to database:

let settings
      | version < 80200 = "SET datestyle TO ISO;SET client_encoding TO UTF8"
      | otherwise       = "SET datestyle TO ISO;SET client_encoding TO UTF8;SET standard_conforming_strings TO on"
_ <- execute_ wconn settings

This prevents using postgresql-simple for databases that support PostgreSQL protocol, but don't implement all of its features. For instance, connection to cockroachdb fails because it doesn't implement SET datestyle TO ISO.

It would be nice to have an option to omit these SET commands on connection creation.

lpsmith commented 6 years ago

Sounds reasonable to me. You can implement your own connect function via the Internal module, but perhaps it would be better to have a way to do this via the public API? I don't know.

lpsmith commented 6 years ago

Well, even if we don't offer a way to do this via the public interface, we should ensure that there is a semi-standard and reasonably convenient way to implement this function using an Internal module