Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 27 13:07
    dinchand commented #2090
  • Sep 27 11:23
    jilen commented #2261
  • Sep 26 20:21
    scala-steward opened #2262
  • Sep 24 22:37
    dispalt opened #2261
  • Sep 24 12:18
    eGluZl starred getquill/quill
  • Sep 23 16:30
    Daniel-Khodabakhsh commented #245
  • Sep 23 12:21
    scala-steward closed #2194
  • Sep 23 12:21
    scala-steward commented #2194
  • Sep 23 12:21
    scala-steward opened #2260
  • Sep 23 06:48
    jilen commented #2240
  • Sep 23 06:48
    jilen commented #2240
  • Sep 23 06:29
    yurique commented #2249
  • Sep 23 06:14
    jilen commented #2243
  • Sep 23 06:03
    jilen commented #2249
  • Sep 23 05:57
    deusaquilus closed #2226
  • Sep 23 05:53
    deusaquilus commented #2146
  • Sep 23 03:10
    yurique commented #2249
  • Sep 23 01:32
    jilen commented #2249
  • Sep 22 16:10
    yurique commented #2249
  • Sep 22 16:04
    yurique commented #2249
Artūras Šlajus
@arturaz
[error]  found   : qual$1.ctx.IO[Either[String,app.db.CreateNewUserIOResult[app.verticles.http.Routes.Login.Response.Success]],qual$1.ctx.Effect.Read with qual$1.ctx.Effect.Write with qual$1.ctx.Effect.Transaction]
[error]  required: dbCtx.IO[?, _]
[error] Error occurred in an application involving default arguments.
[error]           )(
[error]            ^
[info] qual$1.ctx.IO[Either[String,app.db.CreateNewUserIOResult[app.verticles.http.Routes.Login.Response.Success]],qual$1.ctx.Effect.Read with qual$1.ctx.Effect.Write with qual$1.ctx.Effect.Transaction] <: dbCtx.IO[?, _]?
[info]   qual$1.ctx.type = dbCtx.type?
[info]   false
[info] false
Oleg Pyzhcov
@oleg-py
what if you try an empty refinement, i.e. val ctx: MyDbContext { }?
or even implicit class MyDBContextExts[T <: MyDbContext](t: T { }) extends AnyVal?
Artūras Šlajus
@arturaz
let me try
What do empty braces here do? t: T { }
Oleg Pyzhcov
@oleg-py
it's a refinement type, like T { type Res = Int ; val foo: Long }, except it's empty
Artūras Šlajus
@arturaz
  implicit class MyDBContextExts[T <: MyDBContext](val ctx: T { }) extends AnyVal {
    import ctx._

    def createNewUserLoginResponseIO(args: CreateNewUserArgs)(implicit runtimeCfg: RuntimeAppConfig): IO[
      Either[String, CreateNewUserIOResult[Login.Response.Success]],
      Effect.Read with Effect.Write with Effect.Transaction
    ] = {
          val io_ = dbCtx.createNewUserLoginResponseIO(args)
          val result = performIO(io_).getOrThrowLeft
[error] W:\work\unity\sob-review\server\app\src\main\scala\app\commands\DevGenerateUsers.scala:33:34: type mismatch;
[error]  found   : _1.ctx.IO[scala.util.Either[String,app.db.CreateNewUserIOResult[app.verticles.http.Routes.Login.Response.Success]],_1.ctx.Effect.Read with _1.ctx.Effect.Write with _1.ctx.Effect.Transaction] where val _1: app.db.MyDBContextExts.MyDBContextExts[app.db.MyDBContext]
[error]  required: dbCtx.IO[?, _]
[error] Error occurred in an application involving default arguments.
[error]           val result = performIO(io_).getOrThrowLeft
[error]                                  ^
[info] _1.ctx.IO[scala.util.Either[String,app.db.CreateNewUserIOResult[app.verticles.http.Routes.Login.Response.Success]],_1.ctx.Effect.Read with _1.ctx.Effect.Write with _1.ctx.Effect.Transaction] <: dbCtx.IO[?, _]?
[info]   _1.ctx.type = dbCtx.type?
[info]   false
[info] false
Oleg Pyzhcov
@oleg-py
well, I'm out of dark magics that could help :c
Artūras Šlajus
@arturaz
Heh, thanks for trying though :)
I can always design it other way around but I'm just very confused why the type system thinks the type suddenly changes. I thought returning a dependent type should make it the same type.
Zett98
@Zett98
Any examples on how to integrate quill-ndbc and cats effect?
Alexis Durieux
@alexisdurieux
Hello ! I have an List[(Float, Float)] representing an array of numrange in postgres. I am having an issue with the decoder. The insertion works fine but the returning is not working. Any examples I could get inspired with ? Thank you and happy easter !
implicit def arrayNumrangeEncoder[Col <: Seq[(Float, Float)]]
        : Encoder[Col] = arrayRawEncoder[(Float, Float), Col]
    implicit def arrayNumrangeDecoder[Col <: Seq[(Float, Float)]](
        implicit bf: CBF[(Float, Float), Col]
    ): Decoder[Col] =
      arrayRawEncoder[(Float, Float), Col]
2 replies
discobaba
@uncleweirdo_twitter
Just setting started here; where do I put the sortBy(d.processDt), filter, etc?
val q = quote { for { z <- query[ZipIndex] f <- query[GeneFile] if (f.geneFileId == z.geneFileId) d <- query[GeneDir] if (d.geneDirId == f.geneDirId) } yield (z) }
Oleg Pyzhcov
@oleg-py
you can't sort in for comprehension; if describes filter
discobaba
@uncleweirdo_twitter
so what's the correct approach with a bunch of joins?
Oleg Pyzhcov
@oleg-py
you can still do e.g. q.sortBy(_.something) on quoted bit, you can use explicit .join(...).on(...) syntax instead of for-comprehension, or you can wrap all in giant parentheses.
discobaba
@uncleweirdo_twitter
How do you do table aliases where that is required, e.g. sortBy(t.something)?
Oleg Pyzhcov
@oleg-py
quill automatically uses aliases
you refer to stuff via variables in for comprehensions/lambdas
discobaba
@uncleweirdo_twitter
I'm not getting how I would distinguish between fields with the same name in ZipIndex and GeneFile in the 3rd line, for instance, or how I would tell it which table processDt is coming from in the sortBy.
run(query[ZipIndex].
    join(query[GeneFile]).on((z, f) => z.geneFileId == f.geneFileId).
    join(query[GeneDir]).on((f, d) => f.geneDirId == d.geneDirId).
    filter(uid == lift(uid)).
    sortBy(_.processDt)(Ord.desc).take(1))
Oleg Pyzhcov
@oleg-py
that won't compile because join gives you a tuple2. Join twice gives you a tuple inside a tuple. You would be writing something like e.g. .filter { case ((z, f), d) => d.uid == lift(uid) }.sortBy { case ((z, f), d) => d.processDt }(Ord.desc)
discobaba
@uncleweirdo_twitter
ah, that gives me a little traction. Thanks
N.S. Cutler
@godenji
Been quite awhile, but I believe you can just write:
val q = quote {
  (for {
    (zi, gf) <- ZipIndex join GeneFile on(_.geneFileId == _.geneFileId)
         gd  <- GeneDir join(_.geneDirId == gf.geneDirId) if (uid == lift(uid))
  } yield (zi, gf, gd)).sortBy({ case (_,_,d) => d.processDt })(Ord.desc)
}
run(q)
b-gyula
@b-gyula
Is there a plan to implement Common table expressions ? getquill/quill#580
corentin
@corenti13711539_twitter
Does Quill support filtering on parameters of type Option[A] such that if the type is Some[A] a filter condition is added, but condition is omitted when it's None? Similar to e.g. filterOpt in Slick.
5 replies
ElectricWound
@ElectricWound
I would like to refactor an application towards processing the results of a selection from a large Postgres view by streaming to reduce the memory footprint. My application is built on quill-async-postgres and Akka Streams. Is switching to quill-jdbc-monix and Monix Connect the most concise way to provide the table rows as an Akka streams source? Can anybody share his/her experience on additional refactoring I will have to apply to other existing DAOs that use the quill-async-postgres context, but that require no streaming?
b-gyula
@b-gyula

I know quill analyze deeply what's used in map but is there a way to turn it off? E.g. in the following case it should just recognize result must contain colum id,colA,colB

case class A(id: Int, colA: String)

case class B(colB: Int, as: Seq[A])

case class Table(id: Int, colB: Int, colA: String)

ctx.run( query[Table].map(r => B(r.colB, Seq(A(r.id, r.colA)))))

I get instead:
exception during macro expansion: scala.reflect.macros.TypecheckException: package scala.collection is not a value

Remi Guittaut
@remiguittaut
Hi guys. I was wondering about the interest of using zio-quill, it just removes the need of using zio interop cats isn't it?
redk0m
@redk0m_twitter
case class Person(lastVisit: String)
java.lang.UnsupportedOperationException: Can't read LocalDateValue [value=2000-07-23] as String
but in database this column is Date type, what type i must use or how convert it to String?
Quafadas
@Quafadas

Hi, I'm trying to learn quill (3.7.0) out of a postgres database.


val ctx = new PostgresJdbcContext(LowerCase, new HikariDataSource(config))
import ctx._ 
val check = ctx.quote(query[City]
    .sortBy(_.population)(Ord.descNullsLast).take(5))

ctx.run(check)

val mexCity = 
    ctx.quote(query[City])
    .filter(c => c.name like "%mex%" )

ctx.run(mexCity)

The first of these queries works well. The second fails at runtime with the following message.

Found the following free variables: IdentName(mexCity).
Quotations can't reference values outside their scope directly.
In order to bind runtime values to a quotation, please use the method `lift`.
Example: `def byName(n: String) = quote(query[Person].filter(_.name == lift(n)))`

As far as I tell,it is consistent with the docs...
https://getquill.io/#quotation-sql-specific-operations-like
Anyone have ideas on what I might be doing wrong here?

Urgh. Foolishness...

val mexCity = 
    ctx.quote(query[City]
    .filter(c => c.name like "%mex%" ))

The error message was in fact a good one, telling me I had the brackets in the wrong place. Sorry for spam.

Janghwan Lee
@janghwan

hi I would like to chain filter clauses like

query[Person].filter(p => 
  map.collect({
    case ("name", names)  => liftQuery(names).contains(p.name)
    case ("city", cities) => liftQuery(cities).contains(p.city)
  }).foldLeft(lift(false))(_ || _)
)

but this causes Tree 'map.collect ... ' can't be parsed to 'Ast'
is there any other way to combine filter clauses dynimically?

Luis Gustavo
@lgos44

Hi all!
I need to implement a sortBy with dynamic runtime parameters. Currently Im using:

val query = dSchema.sortBy(item => {
      orderBy.flatMap(_.headOption.map(_.columnName)) match {
        case Some("createdAt") => item.audit.createdAt
        case Some("updatedAt") => item.audit.modifiedAt
        case _ => item.audit.modifiedAt
      }
    }) {
      orderBy.flatMap(_.headOption.map(_.direction)) match {
        case Some(OrderDirection.Asc) => Ord.asc
        case Some(OrderDirection.Desc) => Ord.desc
        case _ => Ord.asc
      }
    }

But we will need to have multiple columns at the same time to the sortBy with match case seems unviable.
I've been experimenting with infix. Is there a way to use infix with sortBy? Can anyone provide an example?

Yisrael Union
@yisraelU
im having some trouble with some sql that is generated when using an implicit class to compare date
I ended up with a sql that looks like this
  1 = event_datetime >= ?
I'm using the comparison operators suggested on the Quill docs page. The error I receive states this is invalid sql
Quafadas
@Quafadas
When using quill in metals / vscode, metals - quill query compilation to SQL shows up as a "problem" in the compiler window
is this intentional?
Zulek
@Zulek

Hello, im using application joins (ver 2.5.4).
Somehow outer select does not contain all columns of table but inner select (in join statements) does and as a result i get "column ... does no exist".

Is there a way to force select all columns from big applicative join with filters?

Zulek
@Zulek
or joins have columns that are not in a scope of particular join (...) statement
Alexander Ioffe
@deusaquilus
@Zulek There were various bugs with older versions of Quill with columns being excluded. Are these columns used in Group By (or other aggregations) but any chance?
5 replies
Alexander Ioffe
@deusaquilus
@all Is anyone using AnyVal encoders? Are your AnyVal instances also case classes or not? In Dotty-Quill they might need to be.
1 reply
SemanticBeeng
@SemanticBeeng
What it the best way to use quill--spark with spark 3.1.1 ?
(forgive me if already discussed)
Lachezar Yankov
@lachezar

Hi, if I have two value types which have the same underlying type (String), is there any way to perform "column update" (assign the value from one of the columns to the other)?

case class Email(email: String) extends AnyVal
case class EmailVerified(emailVerified: String) extends AnyVal

...
... .update(table => table.emailVerified -> table.email, ...

beside infix

Hee Yeon Cho
@aposto
Hello, how to compile list updating.
dynamicQuery[TestEntity].update(set("i", 1), set("l", 2L)) 
// compile error
dynamicQuery[TestEntity].update(list.map(a => set(a._1, a._2):_*))
Alexander Ioffe
@deusaquilus
@lachezar This is basically an update-with-join use case which unfortunately we don't support yet.
Oleg Pyzhcov
@oleg-py
How to do select by a collection of compound keys? I have something like a runtime Vector[((UUID, Int), (UUID, Int))] and need to match on 4 corresponding columns. Using jdbc-monix and postgres.
attempt to liftQuery that vector would fail with "Can't tokenize a non-scalar lifting"
Dan Ellis
@danellis

I'm trying to use a model that has a java.time.Instant field. I've put this in my context class:

        implicit val encodeInstant = MappedEncoding[Instant, LocalDateTime](i => LocalDateTime.ofInstant(i, ZoneOffset.UTC))
        implicit val decodeInstant = MappedEncoding[LocalDateTime, Instant](_.toInstant(ZoneOffset.UTC))

but I'm still getting the "Can't find implicit Decoder[java.time.Instant]" error