postgresql-simple icon indicating copy to clipboard operation
postgresql-simple copied to clipboard

make automatic execution of SET commands right after connect optional

Open dimsmol opened this issue 7 years ago • 2 comments

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.

dimsmol avatar Jun 12 '17 02:06 dimsmol

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 avatar Aug 13 '18 18:08 lpsmith

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

lpsmith avatar Aug 13 '18 19:08 lpsmith