Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
Vitaliy-Savkin
@Vitaliy-Savkin

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

SELECT "x"."name" FROM (SHOW DATABASES STARTS WITH 'ACC_***_DB') AS "x"

and get an error

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

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
@DenisNovac

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(...))?

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

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

      } yield (item, childsCount)
    ).transact(transactor)

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

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

Hello

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 =
    q"""
            import ${c.prefix}._
            run(${c.prefix}.query[$t].filter($filter))
          """
}

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
@deusaquilus

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

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

Example:

@main
def simpleQuery = {
  inline def q = quote {
    query[Person]
  }
  val ctx = new SqlMirrorContext(PostgresDialect, Literal)
  import ctx._

  println(run(q))
}
Thanks to Aggelos Bibodis, Liu Fengyun, Prakhar Saxena and the ScQuilL Group and Jakub Kozłowski.
Special thanks to Nicolas Stucki!
vonchav
@voonchav_gitlab
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
@ajrnz
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
@godenji

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

:rocket:

Quafadas
@Quafadas
Does anyone have an example of customising quill-codegen to spit out companion objects with the case classes?
e-Evolution
@e-Evolution
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
@lj-ditrapani
Hi @ajrnz @deusaquilus . I opened getquill/protoquill#6 regarding missing quill-zio artifact.
vbergeron-ledger
@vbergeron-ledger
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 ? :)
vbergeron-ledger
@vbergeron-ledger
(Issue was apparently caused by upgrading java from 14 to 16. Remains a problem for 14+ users tho)
cgrabows
@cgrabows
val insertResults =
          val insert = quote {
            liftQuery(entries.toList).foreach { item =>
              querySchema[Entry](TableName).insert(item)
            }
          run(insert).size
        }
Tree 'context.querySchema[Entry](cache)' can't be parsed to 'Ast'
Lyall Jonathan Di Trapani
@lj-ditrapani
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
@lj-ditrapani
Oh, and this would be multiple logical databases on the same mysql instance (so could use same connection).
Lyall Jonathan Di Trapani
@lj-ditrapani
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
@lj-ditrapani
Actually, dynamicQuerySchema is what I want.
Lyall Jonathan Di Trapani
@lj-ditrapani
So, needed to downgrade to 3.5.2 for dynamicQuerySchema to work, in case anyone reads this.
Dan Ellis
@danellis
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.
SELECT
    posts.id, posts.title, COUNT(clicks.id)
FROM
    posts LEFT OUTER JOIN clicks ON posts.id = clicks.post_id
WHERE
    posts.author_id = '269286af-3be5-4dad-8b17-96704742b9a5'
    AND posts.timestamp > current_timestamp - '2 week'::interval
GROUP BY
    posts.id
Dan Ellis
@danellis

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
        .groupBy(_.postId)
        .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
@danellis
I think I'm getting closer, but the generated query still uses COUNT(*). How can I change that to COUNT(clicks.id)?
Nechama-Miller
@Nechama-Miller
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
@lj-ditrapani
@Nechama-Miller I'm not sure I get your question. But maybe try: filter(item => lift(option.getOrElse(null)) == item)
jadd123
@jadd123
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?
vonchav
@voonchav_gitlab
Hi @deusaquilus and other contributors, I've made a PR to upgrade Quill modules to ScalaJs 1.x. Please review. Thanks.
https://github.com/getquill/quill/pull/2167sbt
voropaevp
@voropaevp
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
@Swoorup
haha
you can follow the warning and try increasing the heap size
n0tel
@n0tel
hi, how can i print DynamicQuery string?
voropaevp
@voropaevp
@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?
voropaevp
@voropaevp
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
@deusaquilus
@all Anyone interested, please come join the Quill Release Party! This Friday at 9:00 AM PST.
https://twitter.com/zivergetech/status/1408019275785412610
@voropaevp It shouldn't need that much memory. I'm running Quill builds in Github CI and they have a 5GB max. What kind of queries are you writing?
@n0tel You can use context.translate(qry) or create a SqlMirrorContext.
@voonchav_gitlab Thanks! Will have a look
Alexander Ioffe
@deusaquilus
@jadd123 If the record doesn't exist the update won't run in the first place. I'm not sure how something like that would work. Can you craft an SQL query to do that?
Kyle Schiller
@kschillz

hello! i'm having trouble compiling a dynamic query. i'm trying to do this

val query = dynamicQuery[Tier]
      .filter(_.id ==id)
      .update(setOpt(_.name, request.name))
    run(query)

but i'm getting the error

[error] Repository.scala:65:9: type mismatch;
[error]  found   : DAO.this.context.DynamicUpdate[Tier]
[error]  required: DAO.this.context.Quoted[Tier]
[error]     run(query)
[error]         ^
[error] one error found

do i have to do something other than run to run a dynamic query? or something to turn query into a Quoted?

Kyle Schiller
@kschillz
i forgot to mention, if i try run(quote(query)), i get a slightly different error:
[error] Repository.scala:65:14: type mismatch;
[error]  found   : DAO.this.context.Quoted[DAO.this.context.DynamicUpdate[Tier]]{def quoted: io.getquill.ast.Ident; def id1060349144(): Unit; val liftings: Object}
[error]  required: DAO.this.context.Quoted[Tier]
[error]     run(quote(query))
[error]              ^
[error] one error found
Matthew de Detrich
@mdedetrich
So I am having issues with one of the images for docker-compose used for testing
When I try to run docker-compose run --rm setup I get the following
Pulling sqlserver (microsoft/mssql-server-linux:)...
ERROR: manifest for microsoft/mssql-server-linux:latest not found: manifest unknown: manifest unknown
Matthew de Detrich
@mdedetrich
Created PR at getquill/quill#2183 to fix above issue
Matthew de Detrich
@mdedetrich
Also another PR here (I noticed the Scala.js tests weren't really running) getquill/quill#2184
Matthew de Detrich
@mdedetrich
@deusaquilus @voropaevp getquill/quill#2184 also fixes the memory issue you guys were talking about. I noticed this as well and simply upgrading the SBT version seems to fix this problem (and make the tests run a lot faster)
rarefiedowl
@rarefiedowl:matrix.org
[m]
Is there a limit of 15 fields to a case class utilized in a quill insert query? I'm encountering an error Can't find an implicit InsertMeta when I add an 16th field to my class. I'm new to quill and scala in case this is a stupid question...
1 reply
rarefiedowl
@rarefiedowl:matrix.org
[m]
Here's how I'm using it, in case it helps. This works if I remove any one of the fields in PPAD.
case class PPAD (a: Int, b: Date, c: Long, d: String, e: String, f: String, g: String, 
                 h: Double, i: String, j: String, k: Double, l: Boolean, m: Option[Int],
                 n: Option[Long], o: Option[String], p: String
                )

...

    import statsCtx._

    val ppad: List[PPAD] = List()
    val q1 = quote {
      liftQuery(ppad).foreach(pa => query[PPAD].insert(pa).onConflictIgnore)
    }
    statsCtx.run(q1)