Questions tagged [doobie]
Doobie is a pure functional JDBC layer for Scala and Cats.
doobie
105
questions
0
votes
1
answer
58
views
scala skunk Multiple parameter Query: Passing List as Parameter to prepared statement
I would like to query a db table using the following sql
val ALL_BY_ID: Query[List[String] *: Int *: EmptyTuple, Store] =
sql"""SELECT id, name, description, account, enterdate
...
0
votes
1
answer
77
views
how to implement error handling with doobie
override def getUser(uuid: UUID): F[Either[String, User]] = {
val query = sql"""SELECT email, password FROM "user" WHERE "userId" = $uuid """
...
0
votes
0
answers
30
views
scala load json data from postgres sql into the domain object error ArrayIndexOutOfBoundsException
I am writing scala code to load data from db (postgres) using following sql.
SELECT
a.id,
a.act_type_id AS actTypeId
COALESCE(json_agg(x.procedure_id), '[]'::json) as actProcIds
FROM
...
1
vote
1
answer
147
views
Manage doobie connections with Hikari
I am connecting and firing queries on postgres in my scala play framework application. While optimizing my application, I saw that before firing any query a CONNECT call is being made to Postgres ...
0
votes
1
answer
59
views
Why does importing Doobie before Circe raise a compilation error?
Just made a discovery while working with Doobie and Circe in the same file.
Not my first time working with both libraries but never really paid attention to the order in which they are imported.
Scala,...
0
votes
0
answers
84
views
Ambiguous Implicit Resolution Error With Doobie
I have this function that inserts a One To Many relationship representation between 3 tables:
def insertRelations(cs: TableA): Fragment = {
sql"""INSERT INTO my_schema.table_a (
...
0
votes
0
answers
44
views
H2 Database File Corrupted Error When Connecting From Application
I have a database file like this in my local folder:
Wed Sep 13 07:46:05 2023 cpo-platform-h2-test.db.mv.db
Wed Sep 13 07:46:44 2023 cpo-platform-h2-test.db.trace.db
Whenever I connect to this ...
0
votes
1
answer
118
views
Scala Cats Effect Wrapping an Implementation from the Effect Type of the Enclosing Class
I have an implementation that looks like this:
final class MyServiceImpl[M[_]: Async](dbCfg: DBConfig)(implicit ec: Scheduler) extends MyService[M] {
......
......
......
......
}
Inside this ...
0
votes
1
answer
95
views
Doobie upgrade from 1.0.0-RC2 to 1.0.0-RC4 causes fragments.or not to compile
My code (below) is failing to compile after a Doobie library upgrade. fragments.or(filterFragments: _*) "Cannot resolve overloaded method 'or'". Presumably the signature has changed but I ...
4
votes
1
answer
260
views
WIth doobie, how do I map Scala case class to postgresql column with type tstzmultirange?
So e.g. I create the table vacations in postgres:
create table if not exists vacations (
person text primary key,
vacations tstzmultirange not null
)
And on the Scala side, I have:
case class ...
0
votes
1
answer
336
views
Doobie cannot find or construct a Read instance for Type of case class with Timestamp
Given a case class representation of a data row with a java.sql.Timestamp:
case class ExampleRow(id: String, ts: Timestamp)
And query expecting an ExampleRow:
import doobie._
import doobie....
0
votes
0
answers
67
views
Refactoring my for comprehension to remove the unsafe get calls on the option values
So my for comprehension technically compiles fine currently, but if you look carefully I have a few unsafe .get calls on the options.
for {
maybeProduct: Option[Product] <- EitherT.liftF {
...
1
vote
0
answers
369
views
Create clickhouse temporary table with doobie
I want to create clickhouse temporary table with doobie, but i don't know how to add session_id parameter in query
I tried
val sql =
sql"CREATE TEMPORARY TABLE " ++ Fragment.const(...
0
votes
0
answers
66
views
How to refactor so I can return different types in my case statement and then execute the doobie queries
Based on the match condition I will need to execute a different doobie query, and these queries may return different Right types in their Eithers.
The problem currently is that sometimes the Right of ...
1
vote
1
answer
315
views
Scala, Doobie, PostgreSQL - how to select from array/jsonb column?
I have a simple db table:
create table if not exists players
(
id bigint,
name text,
results text[]
);
Now I would like to create select query, where I want only rows with passed results. So I ...