Questions tagged [doobie]
Doobie is a pure functional JDBC layer for Scala and Cats.
doobie
105
questions
0
votes
1
answer
60
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
80
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
31
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
155
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,...
2
votes
1
answer
1k
views
Transactions in Doobie for Scala / Play Framework
I have a question regarding transactions in doobie.
I have looked over the documentation here and it looks like it can only handle one query at a time?
Is it possible to have something like this
sql'''...
0
votes
1
answer
120
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 ...
2
votes
2
answers
452
views
Scala Doobie. Creating and Inserting into a Temp Table
I am relatively new to Scala and also new to Doobie. I am connecting to SQL Server 2014 and need to create a temp table and subsequently insert into that temp table. In SQL Server, when you create a ...
0
votes
0
answers
90
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
96
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
262
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
347
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
374
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(...