Skip to content

Commit c6f3b86

Browse files
committed
linting
1 parent d6a96db commit c6f3b86

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

duck4s-cats-effect/src/DuckDBException.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ object DuckDBException:
4747
* A DuckDBException wrapping the given error
4848
*/
4949
def from(error: DuckDBError): DuckDBException = error match
50-
case DuckDBError.ConnectionError(msg, cause) => DuckDBException(error, msg, cause)
51-
case DuckDBError.QueryError(msg, _, cause) => DuckDBException(error, msg, cause)
52-
case DuckDBError.TransactionError(msg, cause) => DuckDBException(error, msg, cause)
53-
case DuckDBError.ConfigurationError(msg) => DuckDBException(error, msg)
54-
case DuckDBError.InvalidStateError(msg) => DuckDBException(error, msg)
50+
case DuckDBError.ConnectionError(msg, cause) =>
51+
DuckDBException(error, msg, cause)
52+
case DuckDBError.QueryError(msg, _, cause) =>
53+
DuckDBException(error, msg, cause)
54+
case DuckDBError.TransactionError(msg, cause) =>
55+
DuckDBException(error, msg, cause)
56+
case DuckDBError.ConfigurationError(msg) => DuckDBException(error, msg)
57+
case DuckDBError.InvalidStateError(msg) => DuckDBException(error, msg)

duck4s-cats-effect/src/DuckDBIO.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ object DuckDBIO:
5757
* @return
5858
* A [[Resource]] that manages the connection lifecycle.
5959
*/
60-
def connect(config: DuckDBConfig = DuckDBConfig.inMemory): Resource[IO, DuckDBConnection] =
60+
def connect(
61+
config: DuckDBConfig = DuckDBConfig.inMemory
62+
): Resource[IO, DuckDBConnection] =
6163
Resource.make(
6264
IO.blocking(DuckDBConnection.connect(config)).flatMap(liftE)
6365
)(conn => IO.blocking(conn.close()))
@@ -80,7 +82,9 @@ object DuckDBIO:
8082
* @return
8183
* A [[fs2.Stream]] that emits one element per row.
8284
*/
83-
def stream[A](conn: DuckDBConnection, sql: String)(f: DuckDBResultSet => A): Stream[IO, A] =
85+
def stream[A](conn: DuckDBConnection, sql: String)(
86+
f: DuckDBResultSet => A
87+
): Stream[IO, A] =
8488
Stream
8589
.resource(
8690
Resource.make(
@@ -89,7 +93,8 @@ object DuckDBIO:
8993
)
9094
.flatMap: rs =>
9195
Stream.unfoldEval(rs): rs =>
92-
IO.blocking(rs.next()).map(hasNext => Option.when(hasNext)(f(rs) -> rs))
96+
IO.blocking(rs.next())
97+
.map(hasNext => Option.when(hasNext)(f(rs) -> rs))
9398

9499
/** Extension methods providing effectful versions of [[DuckDBConnection]]
95100
* operations. Import `com.softinio.duck4s.effect.*` to use these.
@@ -140,7 +145,9 @@ extension (conn: DuckDBConnection)
140145
* @return
141146
* An `IO[T]` with the result of the block.
142147
*/
143-
def withPreparedStatementIO[T](sql: String)(block: DuckDBPreparedStatement => IO[T]): IO[T] =
148+
def withPreparedStatementIO[T](
149+
sql: String
150+
)(block: DuckDBPreparedStatement => IO[T]): IO[T] =
144151
Resource
145152
.make(conn.prepareStatementIO(sql))(stmt => IO.blocking(stmt.close()))
146153
.use(block)
@@ -175,8 +182,8 @@ extension (conn: DuckDBConnection)
175182
*
176183
* Disables auto-commit before running the block. On success, commits the
177184
* transaction. On failure (any raised error), rolls back the transaction.
178-
* Auto-commit is restored to `true` in a `guarantee` finalizer regardless
179-
* of outcome.
185+
* Auto-commit is restored to `true` in a `guarantee` finalizer regardless of
186+
* outcome.
180187
*
181188
* @param block
182189
* A function receiving this connection and returning an `IO[T]`.

duck4s-cats-effect/test/src/DuckDBIOTest.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class DuckDBIOTest extends CatsEffectSuite:
3131
test("executeUpdateIO / executeQueryIO round-trip") {
3232
DuckDBIO.connect().use { conn =>
3333
for
34-
_ <- conn.executeUpdateIO("CREATE TABLE test (id INTEGER, name VARCHAR)")
34+
_ <- conn.executeUpdateIO(
35+
"CREATE TABLE test (id INTEGER, name VARCHAR)"
36+
)
3537
_ <- conn.executeUpdateIO("INSERT INTO test VALUES (1, 'Alice')")
3638
rs <- conn.executeQueryIO("SELECT * FROM test")
3739
_ <- IO(assert(rs.next()))
@@ -47,7 +49,10 @@ class DuckDBIOTest extends CatsEffectSuite:
4749
for
4850
_ <- conn.executeUpdateIO("CREATE TABLE nums (n INTEGER)")
4951
_ <- conn.executeUpdateIO("INSERT INTO nums VALUES (1),(2),(3)")
50-
rows <- DuckDBIO.stream(conn, "SELECT n FROM nums")(_.getInt("n")).compile.toList
52+
rows <- DuckDBIO
53+
.stream(conn, "SELECT n FROM nums")(_.getInt("n"))
54+
.compile
55+
.toList
5156
_ <- IO(assertEquals(rows, List(1, 2, 3)))
5257
yield ()
5358
}
@@ -86,7 +91,7 @@ class DuckDBIOTest extends CatsEffectSuite:
8691

8792
test("DuckDBException wraps ConnectionError") {
8893
val error = DuckDBError.ConnectionError("test connection error")
89-
val ex = DuckDBException.from(error)
94+
val ex = DuckDBException.from(error)
9095
assertEquals(ex.getMessage, "test connection error")
9196
assertEquals(ex.error, error)
9297
assert(ex.getCause == null)
@@ -95,7 +100,7 @@ class DuckDBIOTest extends CatsEffectSuite:
95100
test("DuckDBException wraps QueryError with cause") {
96101
val cause = new RuntimeException("jdbc failure")
97102
val error = DuckDBError.QueryError("query failed", "SELECT 1", Some(cause))
98-
val ex = DuckDBException.from(error)
103+
val ex = DuckDBException.from(error)
99104
assertEquals(ex.getMessage, "query failed")
100105
assertEquals(ex.error, error)
101106
assertEquals(ex.getCause, cause)

0 commit comments

Comments
 (0)