Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jul 23 18:12
    virusdave commented #2146
  • Jul 23 16:08
    sloanesturz edited #2211
  • Jul 23 16:08
    sloanesturz edited #2211
  • Jul 23 08:46
    yuanyedc starred getquill/quill
  • Jul 23 08:01
    mutoulbj starred getquill/quill
  • Jul 23 07:01
    sloanesturz edited #2211
  • Jul 23 05:15
    virusdave commented #2210
  • Jul 23 01:34
    sloanesturz commented #2211
  • Jul 23 01:33
    sloanesturz commented #2211
  • Jul 22 21:40
    sloanesturz edited #2211
  • Jul 22 21:39
    sloanesturz edited #2211
  • Jul 22 21:39
    sloanesturz synchronize #2211
  • Jul 22 21:38
    sloanesturz opened #2211
  • Jul 22 21:37
    sloanesturz opened #2210
  • Jul 22 21:22
  • Jul 22 03:05
    uazw starred getquill/quill
  • Jul 21 11:58
    Kensuke-Hinata starred getquill/quill
  • Jul 21 11:55
    gcnyin starred getquill/quill
  • Jul 19 20:57
    scala-steward closed #2141
  • Jul 19 20:57
    scala-steward commented #2141
Oleg Pyzhcov
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!


Does anyone have an example of customising quill-codegen to spit out companion objects with the case classes?
Hi @deusaquilus, thank you very much for your great work, have you any plans to integrate ksqlDB https://ksqldb.io into the Quill Context family?
Lyall Jonathan Di Trapani
Hi @ajrnz @deusaquilus . I opened getquill/protoquill#6 regarding missing quill-zio artifact.
Hello ! We got quite a nasty problem over there, using quill-cassandra.
We fail to get the InsertMeta implicit for a row with 16 Fields. 15 is fine tho. Anyone got clues ? :)
(Issue was apparently caused by upgrading java from 14 to 16. Remains a problem for 14+ users tho)
val insertResults =
          val insert = quote {
            liftQuery(entries.toList).foreach { item =>
Tree 'context.querySchema[Entry](cache)' can't be parsed to 'Ast'
Lyall Jonathan Di Trapani
Hello. What is the "right" way to deal with querying multiple databases in the same process? Create one context per database? I'm using quill-jasync-mysql in case that is relevant.
Lyall Jonathan Di Trapani
Oh, and this would be multiple logical databases on the same mysql instance (so could use same connection).
Lyall Jonathan Di Trapani
Looks like I can use https://getquill.io/#extending-quill-infix to dynamically generate the <database>.<table> for the queries and just have one context. I'll give that a shot. For my case, there are 100s of databases, so having a context for each is probably bad.
Lyall Jonathan Di Trapani
Actually, dynamicQuerySchema is what I want.
Lyall Jonathan Di Trapani
So, needed to downgrade to 3.5.2 for dynamicQuerySchema to work, in case anyone reads this.
Dan Ellis
Can someone explain how I should turn this into a Quill query? I can't seem to get the groupBy and the filter to work properly. The SQL query itself does give me what I want.
    posts.id, posts.title, COUNT(clicks.id)
    posts LEFT OUTER JOIN clicks ON posts.id = clicks.post_id
    posts.author_id = '269286af-3be5-4dad-8b17-96704742b9a5'
    AND posts.timestamp > current_timestamp - '2 week'::interval
Dan Ellis

This was my best attempt:

for {
    post <- Posts
        .leftJoin(Clicks).on((p, c) => p.id == c.postId)
        .map { case (post, _) => post }
        .filter(p => p.authorId == lift(userId) && p.isDeleted == lift(false))
    clickCount <- Clicks
        .map { case (_, clicks) => clicks.size }
} yield ClickCount(post.id, post.title, clickCount)

but that gives me this compile-time error:

exception during macro expansion: 
java.lang.IllegalStateException: The monad composition can't be expressed using applicative joins. Faulty expression: 'p.id'. Free variables: 'List(p)'., Faulty expression: 'p.title'. Free variables: 'List(p)'.
Dan Ellis
I think I'm getting closer, but the generated query still uses COUNT(*). How can I change that to COUNT(clicks.id)?
Hi, how can I have one query that checks for nulls or a value, I want to pass in an Option and if its None filter by nulls if Some filter by the value. Is there any way to do this without having separate queries?
Lyall Jonathan Di Trapani
@Nechama-Miller I'm not sure I get your question. But maybe try: filter(item => lift(option.getOrElse(null)) == item)
hey there, I'm trying to do an update with a returning clause (which I think specifies what is returned after the update, can someone confirm) how can I return an option in case the record I'm trying to return does not exist?
Hi @deusaquilus and other contributors, I've made a PR to upgrade Quill modules to ScalaJs 1.x. Please review. Thanks.
How much memory do I need to run the test suite? My system has 32GB and I'm getting
[warn] In the last 9 seconds, 5.127 (60.2%) were spent in GC. [Heap: 0.37GB free of 1.45GB, max 1.45GB] Consider increasing the JVM heap using `-Xmx` or try a different collector, e.g. `-XX:+UseG1GC`, for better performance.
java.lang.OutOfMemoryError: Java heap space
[error] [launcher] error during sbt launcher: java.lang.OutOfMemoryError: Java heap space
Swoorup Joshi
you can follow the warning and try increasing the heap size
hi, how can i print DynamicQuery string?
@Swoorup I will do. But my system was swapping when this error occur. I'm not sure it will help. How much memory does it normally use?
by trial and error got the -Xmx10g (5g was failing, 7g was slow). And it has to be modified in docker-compose.conf, project.sbt value/-J were overridden by docker's environment.
Alexander Ioffe
@all Anyone interested, please come join the Quill Release Party! This Friday at 9:00 AM PST.