Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 08:18
  • 08:18
    yurique starred getquill/quill
  • Jul 27 19:43
    deusaquilus opened #2218
  • Jul 27 19:42

    deusaquilus on fix-onconflict-stuff

    Fixing on-conflict case with qu… (compare)

  • Jul 27 18:25
    scala-steward opened #2217
  • Jul 27 17:35

    deusaquilus on fix-onconflict-stuff

    Working on on-conflict stuff (compare)

  • Jul 27 11:18
    xeppaka starred getquill/quill
  • Jul 26 16:48
    scala-steward closed #2208
  • Jul 26 16:48
    scala-steward commented #2208
  • Jul 26 16:48
    scala-steward opened #2216
  • Jul 26 11:39
    dev590t commented #2214
  • Jul 25 16:03
    dev590t edited #2214
  • Jul 25 15:38
    dev590t commented #2214
  • Jul 25 15:22
    dev590t commented #2214
  • Jul 25 15:20
    dev590t commented #2214
  • Jul 25 14:58
    TheDIM47 opened #2215
  • Jul 25 13:55
    dev590t edited #2214
  • Jul 25 13:48
    dev590t edited #2214
  • Jul 25 13:46
    dev590t commented #2214
  • Jul 25 13:45
    dev590t commented #2214
Oleg Pyzhcov
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)
ah, that gives me a little traction. Thanks
N.S. Cutler
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)
Is there a plan to implement Common table expressions ? getquill/quill#580
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
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?

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
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?
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?

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]


val mexCity = 
    .filter(c => c.name like "%mex%" )


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...
Anyone have ideas on what I might be doing wrong here?

Urgh. Foolishness...

val mexCity = 
    .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

hi I would like to chain filter clauses like

query[Person].filter(p => 
    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

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
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
When using quill in metals / vscode, metals - quill query compilation to SQL shows up as a "problem" in the compiler window
is this intentional?

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?

or joins have columns that are not in a scope of particular join (...) statement
Alexander Ioffe
@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
@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
What it the best way to use quill--spark with spark 3.1.1 ?
(forgive me if already discussed)
Lachezar Yankov

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
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
@lachezar This is basically an update-with-join use case which unfortunately we don't support yet.
Oleg Pyzhcov
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

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

I've also tried putting it after my import ctx._
Remi Guittaut
Hi guys, in quill 3.7.0 for whatever reason, the generated sql queries are not displayed at compile time anymore. Do you have the same problem? (I don't have -Dquill.macro.log=false in my build definition)
Are there any sample projects besides quill-example and play-quill-jdbc repos? How do you maintain sample projects? (In Slick there's a lot of code in the SBT build dealing with it, which I'd like to simplify or eliminate, and I'm trying to find out what other people do.) Do you automate keeping them up to date, and if so, how? /cc @deusaquilus
Philippe Derome
I am getting a macro TypecheckException for no implicit Decoder when using H2ZioJdbcContext. What is it generally indicative of?
[error] scala.reflect.macros.TypecheckException: Can't find implicit `Decoder[Foo]`. Please, do one of the following things:
[error] 1. ensure that implicit `Decoder[Foo]` is provided and there are no other conflicting implicits;
[error] 2. make `Foo` `Embedded` case class or `AnyVal`.
[error]         at scala.reflect.macros.contexts.Typers.$anonfun$typecheck$3(Typers.scala:44)
[error]         at scala.reflect.macros.contexts.Typers.$anonfun$typecheck$2(Typers.scala:38)
[error]         at scala.reflect.macros.contexts.Typers.doTypecheck$1(Typers.scala:37)
[error]         at scala.reflect.macros.contexts.Typers.$anonfun$typecheck$7(Typers.scala:50)
[error]         at scala.reflect.internal.Trees.wrappingIntoTerm(Trees.scala:1891)
[error]         at scala.reflect.internal.Trees.wrappingIntoTerm$(Trees.scala:1888)
[error]         at scala.reflect.internal.SymbolTable.wrappingIntoTerm(SymbolTable.scala:28)
[error]         at scala.reflect.macros.contexts.Typers.typecheck(Typers.scala:50)
[error]         at scala.reflect.macros.contexts.Typers.typecheck$(Typers.scala:32)
[error]         at scala.reflect.macros.contexts.Context.typecheck(Context.scala:18)
[error]         at scala.reflect.macros.contexts.Context.typecheck(Context.scala:18)
[error]         at io.getquill.context.QueryMacro.expandQueryWithMeta(QueryMacro.scala:125)
[error]         at io.getquill.context.QueryMacro.expandQuery(QueryMacro.scala:51)
[error]         at io.getquill.context.QueryMacro.runQuery(QueryMacro.scala:34)
never mind that, I have some more basic questions/issues to address/understand. I'll ask something simpler if required.
Philippe Derome
It seems to be about invalid usage of nesting of case classes, which makes sense that I'd need Decoder or Encoder for nesting case classes.
so the type parameter T in EntityQuery[T] has nested case classes.
Philippe Derome
looks like the doc tells me what I should be doing: https://getquill.io/#quotation-schema-embedded-case-classes
that was it.
hello. Can i use pattern matching on DynamicQuery. Like this:
schemaOne.dynamic.join(schemaTwo).on(_.id == _.id).groupBy  { case  quoted =>  // i want case (schema1, schema2) here

How can i use dynamic query with implicit joins?

// Implicit Joins:
quote {
  for {
    a <- query[A]
    b <- query[B] if (a.id == b.fk) 
  } yield (a, b)

if i use dynamic query, this code return DynamicQuery[Quoted[Schema1], Quoted[Schema2]]:

// Implicit Joins:
val dynamicQ = quote {
  for {
    a <- query[A].dynamic
    b <- query[B].dynamic if (a.id == b.fk) 
  } yield (a, b)

and if i then use groupBy, im getting error The query definition must happen within aquoteblock. [error] b.groupBy(_._1)


Hi, can I somehow force quill to execute exactly the same sql I specified via infix?
When I execute this code

case class NamedEntity(name: String)
val rawQuery = s"SHOW DATABASES STARTS WITH '$dbName'"
run(quote(infix"#$rawQuery".as[Query[NamedEntity]])).exists(_.name == dbName)

I see query


and get an error

SQL compilation error:
syntax error line 1 at position 24 unexpected 'SHOW'.
2 replies

How i can write this query using quill ? (postgres)

select * from ( values ('Albert', 'Einstein'), ('Nicola', 'Tesla') ) s (name, lastName)

Query, that return predefined values (not from DB)

Denis Novac

Hi everyone. I am trying to make join of count, but i getting stuck with Tuple(Quoted, Quoted). Is there any way to make it Quoted(Tuple(...))?

      for {
        item <- items.dynamic
                  .filter(_.id == lift(id))

        childsCount = items.dynamic
                  .filter(_.parent == lift(Some(item.id)))

      } yield (item, childsCount)

The output type is Stream[F, (Quoted[Item], Quoted[Long])], but it should be Stream[F, (Item, Long)]

Denis Novac
I guess i just don't really need dynamic call here. It works without it.


I'm trying to write a generic code with Quill to perform some operation on multiple datatype, as described in https://stackoverflow.com/questions/44784310/how-to-write-generic-function-with-scala-quill-io-library/44797199#44797199

I've created my macro

class FindMacro(val c: MacroContext) {
  import c.universe._

  def find[T](filter: Tree)(implicit t: WeakTypeTag[T]): Tree =
            import ${c.prefix}._

That I'm then using in my generic trait:

trait Indexed[I, T] {
  def find(key: I, obj: T): Boolean

trait Storage[I, T] {
  def get(idx: I)(implicit eq: Indexed[I, T]): Task[Option[T]]

trait Queries { this: ZioJdbcContext[_, _] =>
  def find[T](filter: T => Boolean): T = macro FindMacro.find[T]

case class SqliteStorage[I, T](connection: Connection)(implicit schema: SchemaMeta[T]) extends Storage[I, T] {

  val ctx = new SqliteZioJdbcContext(SnakeCase) with Queries

  override def get(idx: I)(implicit eq: Indexed[I, T]): Task[Option[T]] =
    ctx.find[T](p => eq.find(idx, p))


Unfortunately, the implicit SchemaMeta[T] does not seems to work, I think I must be missing something here, but I don't understand what, could someone help me with that ?

Alexander Ioffe

ProtoQuill (i.e. Dotty-Quill) Beta-1 is out!

// build.sbt
lazy val root = project
    scalaVersion := "3.0.0",
    libraryDependencies ++= Seq(
      "io.getquill" %% "quill-jdbc" %"3.7.1.Beta1.0"


def simpleQuery = {
  inline def q = quote {
  val ctx = new SqlMirrorContext(PostgresDialect, Literal)
  import ctx._

Thanks to Aggelos Bibodis, Liu Fengyun, Prakhar Saxena and the ScQuilL Group and Jakub Kozłowski.
Special thanks to Nicolas Stucki!
Hi @deusaquilus, is there a blocker on supporting ScalaJS v1.x? Currently quill-core is still on scalajs 0.6.x. If there isn't a known issue, I can try and submit a PR.
Andrew Richards
For protoquill: quill-jdbc-zio requires quill-zio which doesn't seem to be published for scala 3 (3.7.1.Beta1.0)
N.S. Cutler

ProtoQuill (i.e. Dotty-Quill) Beta-1 is out!