File tree Expand file tree Collapse file tree 3 files changed +6
-17
lines changed
ihp-datasync/IHP/DataSync Expand file tree Collapse file tree 3 files changed +6
-17
lines changed Original file line number Diff line number Diff line change 9191 url = "https://hackage.haskell.org/package/postgresql-binary-0.15/postgresql-binary-0.15.tar.gz" ;
9292 sha256 = "11ysy91rsvdx9n7cjpyhp23ikv3h9b40k6rdggykhjkdv7vdvhj3" ;
9393 } ) { } ) ) ;
94+ # Patched to fix parsing of empty password in URI format (user:@host)
95+ # See: https://github.com/nikita-volkov/postgresql-connection-string/pull/3
9496 postgresql-connection-string = fastBuild ( self . callCabal2nix "postgresql-connection-string" ( builtins . fetchTarball {
95- url = "https://hackage.haskell.org/package /postgresql-connection-string-0.1/postgresql-connection-string-0.1 .tar.gz" ;
96- sha256 = "071m8xzqak2b0l27zplfknsdq8x91k0iwimqikszdvdcj6mp1c6r " ;
97+ url = "https://github.com/mpscholten /postgresql-connection-string/archive/bb9bfb8cfff39e0e87aa24208d0e34a0cefb13cc .tar.gz" ;
98+ sha256 = "1jw3ka11anvx9prr5iliqwi42h5jlwbq8i0xlarzq2hgg3sc0sqp " ;
9799 } ) { } ) ;
98100
99101 hasql = final . haskell . lib . dontCheck ( final . haskell . lib . doJailbreak ( fastBuild ( self . callCabal2nix "hasql" ( builtins . fetchTarball {
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import qualified Hasql.Connection as Hasql
1111import qualified Hasql.Connection.Settings as HasqlSettings
1212import qualified Hasql.Session as Session
1313import qualified Hasql.Errors as Hasql
14- import qualified Data.Text as Text
1514
1615-- | Run a composed Session against the pool. Throws 'Hasql.Pool.UsageError' on failure.
1716runSession :: Hasql.Pool. Pool -> Session. Session a -> IO a
@@ -38,13 +37,7 @@ runSessionOnConnection conn session = do
3837-- action completes (normally or via exception).
3938withDedicatedConnection :: ByteString -> (Hasql. Connection -> IO a ) -> IO a
4039withDedicatedConnection databaseUrl action = do
41- -- Normalize for hasql's connection string parser:
42- -- 1. postgres:// → postgresql://
43- -- 2. Strip empty password (user:@host) → (user@host) — parser chokes on empty password
44- let hasqlDatabaseUrl = cs databaseUrl
45- |> Text. replace " postgres://" " postgresql://"
46- |> Text. replace " :@" " @"
47- connResult <- Hasql. acquire (HasqlSettings. connectionString hasqlDatabaseUrl)
40+ connResult <- Hasql. acquire (HasqlSettings. connectionString (cs databaseUrl))
4841 case connResult of
4942 Right conn -> action conn `Exception.finally` Hasql. release conn
5043 Left err -> error (Hasql. toDetailedText err)
Original file line number Diff line number Diff line change @@ -103,14 +103,8 @@ createModelContext idleTime maxConnections databaseUrl logger = do
103103 -- HASQL_IDLE_TIME: seconds before idle connection is closed (default: 600 = 10 min)
104104 hasqlPoolSize :: Maybe Int <- envOrNothing " HASQL_POOL_SIZE"
105105 hasqlIdleTime :: Maybe Int <- envOrNothing " HASQL_IDLE_TIME"
106- -- Normalize for hasql's connection string parser:
107- -- 1. postgres:// → postgresql://
108- -- 2. Strip empty password (user:@host) → (user@host) — parser chokes on empty password
109- let hasqlDatabaseUrl = cs databaseUrl
110- |> Text. replace " postgres://" " postgresql://"
111- |> Text. replace " :@" " @"
112106 let hasqlPoolSettings =
113- [ HasqlPoolConfig. staticConnectionSettings (HasqlSettings. connectionString hasqlDatabaseUrl )
107+ [ HasqlPoolConfig. staticConnectionSettings (HasqlSettings. connectionString (cs databaseUrl) )
114108 ]
115109 <> maybe [] (\ size -> [HasqlPoolConfig. size size]) hasqlPoolSize
116110 <> maybe [] (\ idle -> [HasqlPoolConfig. idlenessTimeout (fromIntegral idle)]) hasqlIdleTime
You can’t perform that action at this time.
0 commit comments