Questions tagged [doobie]

Doobie is a pure functional JDBC layer for Scala and Cats.

Doobie is a pure functional JDBC layer for Scala and Cats.

It is not an ORM, nor is it a relational algebra; it simply provides a principled way to construct programs (and higher-level libraries) that use JDBC.

http://tpolecat.github.io/doobie/

99 questions
1
vote
0 answers

org.postgresql.util.PSQLException: The column index is out of range

The exception org.postgresql.util.PSQLException: The column index is out of range: 2, number of columns: 1. ... only occurs if a string interpolation is added to the query below, for example: [...]('SRID=4326;Point(${geoPoint.longitude}…
1
vote
1 answer

Doobie example complains about column index mismatch

Trying out the stock Doobie example, and getting an exception complaining about an "Invalid column index". My query is extremely simple: it selects two columns from one Oracle table, and I expect Doobie to map that to a sequence of case class…
radumanolescu
  • 4,059
  • 2
  • 31
  • 44
1
vote
1 answer

Issues when using Doobie library with Oracle and Timestamp

I am trying to use Doobie with oracle and I am getting some type issues: I have a table: create table TEST ( CREATED_ON TIMESTAMP(6) not null, A VARCHAR2(50) not null, B VARCHAR2(50) not null, C …
user3237183
1
vote
2 answers

Get or Insert within a Transaction on Doobie in Scala

I'm reading through the Doobie documentation and trying to do a simple get or create within a transaction. I get an option off the first query and attempt to do a getOrElse and run an insert within the else, however I keep getting a value map is not…
djsumdog
  • 2,560
  • 1
  • 29
  • 55
0
votes
1 answer

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 cant get it work in the same as it did before the upgrade. Am…
Tom Squires
  • 8,848
  • 12
  • 46
  • 72
0
votes
0 answers

scala, Doobie, Postgres - how to continue application run if there is sql error during batch insert

I have a simple doobie batch insert: def insertMe(data: List[SomeData]): ConnectionIO[Unit] = { insert("Insert into some_table (name, age) values (data.name, data.age)")(data) } private def insert[T: Write](sql: String)(data: Iterable[T]):…
Developus
  • 1,400
  • 2
  • 14
  • 50
0
votes
1 answer

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.implicits._ import doobie.postgres.implicits._ val…
Ramón J Romero y Vigil
  • 17,373
  • 7
  • 77
  • 125
0
votes
0 answers

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 { for { a <- ADao.get(123).transact(xa) …
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
0
votes
0 answers

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 my either returns SomeType1 and in another match…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
0
votes
2 answers

Doobie query to create a map

Let's say I have some sql that is going to return a result set that looks like this: ID Value A1 Val1 A1 Val2 A1 Val3 B1 Val4 B1 Val5 B1 Val6 val query = sql"""select blah""".query[(ID, VALUE)] val result: ConnectionIO[(ID,…
Paul McKenzie
  • 19,646
  • 25
  • 76
  • 120
0
votes
1 answer

For comprehension that has to handle 2 optional values and return a Option[T]

The below code works fine, but as you can see the 2nd clause in the for comprehension has a call that is unsafe. case class ProductView(product: Product, stores: List[Store], warehosue: Option[Warehosue]) def loadView(...):…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
0
votes
1 answer

Scala compilation fails with: Could not find implicit value for parameter W

I got a doobie query that doesn't want to compile: package de.x.vmdbplanningvalues.impl.queries import de.x.campaignplans.CampaignPlanId import de.x.distributionbrands.DistributionBrandId import de.x.vmdbplanningvalues._ import doobie._ object…
Johannes Klauß
  • 10,676
  • 16
  • 68
  • 122
0
votes
0 answers

smart constructor for multiple types in one doobie query

I have a case class User: case class User( email: String, username: String, salutation: String, surname: String ) An I have a Query that fills this User case class: sql""" SELECT email, username, salutation, surname FROM…
helloworld
  • 127
  • 1
  • 1
  • 8
0
votes
1 answer

Returning a Stream of Entities using a Transactor inside a Resource in Doobie

I'm trying to implement a query that returns the extracted information inside a fs2.Stream. I defined the Jobs algebra: trait Jobs[F[_]] { def all(): fs2.Stream[F, Job] } Then, I implemented an interpreter for the algebra: final class…
riccardo.cardin
  • 7,971
  • 5
  • 57
  • 106
0
votes
2 answers

Reading data into custom case classes in Doobie

Let's say I have a case class X(id: Int, name: String, age: Int) and some function (in my case, withUniqueGeneratedKeys in doobie) that returns X. If I have already defined X I am good. But in my case the core data structure is something like: case…
cgold
  • 4,075
  • 1
  • 12
  • 13