From 412df86c41e2cc44d9ea3525c4a6f29dc443d4e4 Mon Sep 17 00:00:00 2001 From: David Geirola Date: Fri, 19 Jul 2024 16:43:51 +0200 Subject: [PATCH] Add driver parameter (#319) --- core/src/main/scala-2/fly4s/data/Fly4sConfig.scala | 3 ++- core/src/main/scala-3/fly4s/data/Fly4sConfig.scala | 7 ++++++- core/src/main/scala/fly4s/data/Fly4sConfigBuilder.scala | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala-2/fly4s/data/Fly4sConfig.scala b/core/src/main/scala-2/fly4s/data/Fly4sConfig.scala index bb667ad..7fe46b9 100644 --- a/core/src/main/scala-2/fly4s/data/Fly4sConfig.scala +++ b/core/src/main/scala-2/fly4s/data/Fly4sConfig.scala @@ -53,6 +53,7 @@ case class Fly4sConfig( skipDefaultResolvers: Boolean = defaultSkipDefaultResolvers, // --- mima after 1.0.0 --- loggers: List[LoggerType] = defaultLoggers, - baseJavaConfig: Option[Configuration] = None + baseJavaConfig: Option[Configuration] = None, + driver: Option[String] = defaultDriver ) extends Fly4sConfigContract object Fly4sConfig extends Fly4sConfigBuilder diff --git a/core/src/main/scala-3/fly4s/data/Fly4sConfig.scala b/core/src/main/scala-3/fly4s/data/Fly4sConfig.scala index da832e6..f31775d 100644 --- a/core/src/main/scala-3/fly4s/data/Fly4sConfig.scala +++ b/core/src/main/scala-3/fly4s/data/Fly4sConfig.scala @@ -51,11 +51,16 @@ case class Fly4sConfig( skipDefaultResolvers: Boolean = defaultSkipDefaultResolvers, // --- mima after 1.0.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) diff --git a/core/src/main/scala/fly4s/data/Fly4sConfigBuilder.scala b/core/src/main/scala/fly4s/data/Fly4sConfigBuilder.scala index 545c2d7..71c555b 100644 --- a/core/src/main/scala/fly4s/data/Fly4sConfigBuilder.scala +++ b/core/src/main/scala/fly4s/data/Fly4sConfigBuilder.scala @@ -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 @@ -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), @@ -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)