File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
doobie-hikari-pureconfig/src/main/scala/com/avast/sst/doobie/pureconfig Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .avast .sst .doobie .pureconfig
2
2
3
+ import cats .syntax .either ._
3
4
import com .avast .sst .doobie .DoobieHikariConfig
4
5
import doobie .enum .TransactionIsolation
5
6
import pureconfig .ConfigReader
6
- import pureconfig .generic .semiauto .{deriveEnumerationReader , deriveReader }
7
+ import pureconfig .error .CannotConvert
8
+ import pureconfig .generic .semiauto .deriveReader
7
9
8
10
trait ConfigReaders {
9
11
10
- implicit val transactionIsolationReader : ConfigReader [TransactionIsolation ] = deriveEnumerationReader
12
+ implicit val transactionIsolationReader : ConfigReader [TransactionIsolation ] = ConfigReader [String ].emap {
13
+ case " TRANSACTION_NONE" => TransactionIsolation .TransactionNone .asRight
14
+ case " TRANSACTION_READ_UNCOMMITTED" => TransactionIsolation .TransactionReadUncommitted .asRight
15
+ case " TRANSACTION_READ_COMMITTED" => TransactionIsolation .TransactionReadCommitted .asRight
16
+ case " TRANSACTION_REPEATABLE_READ" => TransactionIsolation .TransactionRepeatableRead .asRight
17
+ case " TRANSACTION_SERIALIZABLE" => TransactionIsolation .TransactionSerializable .asRight
18
+ case unknown => Left (CannotConvert (unknown, " TransactionIsolation" , " unknown value" ))
19
+ }
11
20
12
21
implicit val configReader : ConfigReader [DoobieHikariConfig ] = deriveReader
13
22
You can’t perform that action at this time.
0 commit comments