Skip to content

Commit

Permalink
Add driver parameter (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
geirolz authored Jul 19, 2024
1 parent 1fb8ebb commit 6d39e18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/main/scala-2/fly4s/data/Fly4sConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ case class Fly4sConfig(
skipDefaultResolvers: Boolean = defaultSkipDefaultResolvers,
// --- mima after 0.1.0 ---
loggers: List[LoggerType] = defaultLoggers,
baseJavaConfig: Option[Configuration] = None
baseJavaConfig: Option[Configuration] = None,
driver: Option[String] = defaultDriver
) extends Fly4sConfigContract
object Fly4sConfig extends Fly4sConfigBuilder
7 changes: 6 additions & 1 deletion core/src/main/scala-3/fly4s/data/Fly4sConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ case class Fly4sConfig(
skipDefaultResolvers: Boolean = defaultSkipDefaultResolvers,
// --- mima after 0.1.0 ---
loggers: List[LoggerType] = defaultLoggers,
baseJavaConfig: Option[Configuration] = None
baseJavaConfig: Option[Configuration] = None,
driver: Option[String] = defaultDriver
) extends Fly4sConfigContract
object Fly4sConfig extends Fly4sConfigBuilder:

extension (i: Fly4sConfig)

def withDriver(driver: Option[String]): Fly4sConfig =
i.copy(driver = driver)

def withConnectRetries(connectRetries: Int): Fly4sConfig =
i.copy(connectRetries = connectRetries)

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/scala/fly4s/data/Fly4sConfigBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private[fly4s] trait Fly4sConfigContract {
}

private[fly4s] object Fly4sConfigDefaults {
val defaultDriver: Option[String] = None
val defaultConnectRetries: Int = 0
val defaultInitSql: Option[String] = None
val defaultDefaultSchemaName: Option[String] = None
Expand Down Expand Up @@ -119,6 +120,7 @@ private[fly4s] trait Fly4sConfigBuilder {
new Fly4sConfig(
baseJavaConfig = Some(c),
// ---------- connection ----------
driver = Option(c.getDriver),
connectRetries = c.getConnectRetries,
initSql = Option(c.getInitSql),
defaultSchemaName = Option(c.getDefaultSchema),
Expand Down Expand Up @@ -183,6 +185,7 @@ private[fly4s] trait Fly4sConfigBuilder {

// ---------- connection ----------
fluentConfiguration
.driver(c.driver.orNull)
.connectRetries(c.connectRetries)
.initSql(c.initSql.orNull)
.defaultSchema(c.defaultSchemaName.orNull)
Expand Down

0 comments on commit 6d39e18

Please sign in to comment.