Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query.update(T => (Any, Any), (T => (Any, Any))*) does not support Seq()* style notation. #2978

Open
jmpicnic opened this issue Jan 10, 2024 · 0 comments

Comments

@jmpicnic
Copy link

jmpicnic commented Jan 10, 2024

Scala: 3.3.1
Sbt: 1.9.6
Quill Version: 4.8.0
Module: quill-jdbc-zio
Database: postgres

Expected behavior

The Query.update has the signature: def update(f: (T => (Any, Any)), f2: (T => (Any, Any))*): Update[T] in Model.scala line 90. Based on that signature, the expectation is that both, a varargs invocation as well as a "deconstructed" sequence using the * operator would behave the same.

Actual behavior

An Exception is thrown by the macro processor when the syntax Seq(x1, x2, x3)* is used and no simple error message given. For the example below (in the Steps to Reproduce, the following is the result in two error messages in the sbt output: (with -Dquill.macro.log.pretty=true)

First Error

[error] 28 |      query
[error] 29 |        .filter(_.id == lift(value.id))
[error] 30 |        .update(
[error]    |      ^
[error]    |
[error]    |s"==== Tree cannot be parsed to 'Ast' ====
[error]    |    (Unquote.apply[EntityQuery[Record]](((Quoted.apply[EntityQuery[Record]](Entity.Opinionated.apply("records", Nil, io.getquill.quat.Quat.Product.WithRenamesCompact.apply("Record", io.getquill.quat.Quat.Product.Type.Concrete)("id", "a", "b", "c")(io.getquill.quat.Quat.Value, io.getquill.quat.Quat.Value, io.getquill.quat.Quat.Value, io.getquill.quat.Quat.Value)()(), Renameable.Fixed).asInstanceOf[Ast], Nil, Nil): Quoted[EntityQuery[Record]]): Quoted[EntityQuery[Record]]), "169adb70-5650-4377-ac15-bd6a08321d35").unquote: EntityQuery[Record]).filter(((_$5: Record) => _$5.id.==({
[error]    |  val Context_this: quill.type = quill
[error]    |
[error]    |  (EagerPlanter.apply[Long, PrepareRow, Session](value.id, quill.longEncoder, "6804fb7d-4dcb-41d5-bedd-63c6110088f9").unquote: Long)
[error]    |}))).update(((_$6: Record) => ArrowAssoc[String](_$6.a).->[String]({
[error]    |  val `Context_this₂`: quill.type = quill
[error]    |
[error]    |  (EagerPlanter.apply[String, PrepareRow, Session](value.a, quill.stringEncoder, "2fd449fb-8b87-49b8-961d-0b1613c7f521").unquote: String)
[error]    |})), Seq.apply[Function1[Record, Tuple2[Any, Any]]](List.apply[Any](((_$7: Record) => ArrowAssoc[String](_$7.b).->[String]({
[error]    |  val `Context_this₃`: quill.type = quill
[error]    |
[error]    |  (EagerPlanter.apply[String, PrepareRow, Session](value.b, quill.stringEncoder, "450c9f4c-dfe0-458e-90bd-2f49394a5174").unquote: String)
[error]    |})), ((_$8: Record) => ArrowAssoc[String](_$8.c).->[String]({
[error]    |  val `Context_this₄`: quill.type = quill
[error]    |
[error]    |  (EagerPlanter.apply[String, PrepareRow, Session](value.c, quill.stringEncoder, "7f3eea14-6f58-4a37-9151-0de8e0c94fd6").unquote: String)
[error]    |}))).asInstanceOf[_]): _)
[error]    |==== Extractors ===
[error]    |  Apply(
[error]    |  Select(
[error]    |    Apply(
[error]    |      Select(
[error]    |        Typed(
[error]    |          Select(
[error]    |            Apply(
[error]    |              TypeApply(Select(Ident("Unquote"), "apply"), List(Inferred())),
[error]    |              List(
[error]    |                Typed(
[error]    |                  Typed(
[error]    |                    Apply(
[error]    |                      TypeApply(
[error]    |                        Select(Ident("Quoted"), "apply"),
[error]    |                        List(Inferred())
[error]    |                      ),
[error]    |                      List(
[error]    |                        Inlined(
[error]    |                          Some(TypeIdent("DeserializeAstInstances$")),
[error]    |                          Nil,
[error]    |                          TypeApply(
[error]    |                            Select(
[error]    |                              Inlined(
[error]    |                                None,
[error]    |                                Nil,
[error]    |                                Inlined(
[error]    |                                  Some(TypeIdent("Lifter")),
[error]    |                                  Nil,
[error]    |                                  Apply(
[error]    |                                    Select(
[error]    |                                      Select(Ident("Entity"), "Opinionated"),
[error]    |                                      "apply"
[error]    |                                    ),
[error]    |                                    List(
[error]    |                                      Inlined(
[error]    |                                        None,
[error]    |                                        Nil,
[error]    |                                        Literal(StringConstant("records"))
[error]    |                                      ),
[error]    |                                      Inlined(
[error]    |                                        None,
[error]    |                                        Nil,
[error]    |                                        Inlined(
[error]    |                                          Some(TypeIdent("ToExpr$")),
[error]    |                                          Nil,
[error]    |                                          Ident("Nil")
[error]    |                                        )
[error]    |                                      ),
[error]    |                                      Inlined(
[error]    |                                        None,
[error]    |                                        Nil,
[error]    |                                        Inlined(
[error]    |                                          Some(TypeIdent("Lifter")),
[error]    |                                          Nil,
[error]    |                                          Apply(
[error]    |                                            Apply(
[error]    |                                              Apply(
[error]    |                                                Apply(
[error]    |                                                  Apply(
[error]    |                                                    Select(
[error]    |                                                      Select(
[error]    |                                                        Select(
[error]    |                                                          Select(
[error]    |                                                            Select(
[error]    |                                                              Select(
[error]    |                                                                Ident("io"),
[error]    |                                                                "getquill"
[error]    |                                                              ),
[error]    |                                                              "quat"
[error]    |                                                            ),
[error]    |                                                            "Quat"
[error]    |                                                          ),
[error]    |                                                          "Product"
[error]    |                                                        ),
[error]    |                                                        "WithRenamesCompact"
[error]    |                                                      ),
[error]    |                                                      "apply"
[error]    |                                                    ),
[error]    |                                                    List(
[error]    |                                                      Inlined(
[error]    |                                                        None,
[error]    |                                                        Nil,
[error]    |                                                        Literal(
[error]    |                                                          StringConstant(
[error]    |                                                            "Record"
[error]    |                                                          )
[error]    |                                                        )
[error]    |                                                      ),
[error]    |                                                      Inlined(
[error]    |                                                        None,
[error]    |                                                        Nil,
[error]    |                                                        Inlined(
[error]    |                                                          Some(
[error]    |                                                            TypeIdent(
[error]    |                                                              "Lifter"
[error]    |                                                            )
[error]    |                                                          ),
[error]    |                                                          Nil,
[error]    |                                                          Select(
[error]    |                                                            Select(
[error]    |                                                              Select(
[error]    |                                                                Select(
[error]    |                                                                  Select(
[error]    |                                                                    Select(
[error]    |                                                                      Ident(
[error]    |                                                                        "io"
[error]    |                                                                      ),
[error]    |                                                                      "getquill"
[error]    |                                                                    ),
[error]    |                                                                    "quat"
[error]    |                                                                  ),
[error]    |                                                                  "Quat"
[error]    |                                                                ),
[error]    |                                                                "Product"
[error]    |                                                              ),
[error]    |                                                              "Type"
[error]    |                                                            ),
[error]    |                                                            "Concrete"
[error]    |                                                          )
[error]    |                                                        )
[error]    |                                                      )
[error]    |                                                    )
[error]    |                                                  ),
[error]    |                                                  List(
[error]    |                                                    Typed(
[error]    |                                                      Inlined(
[error]    |                                                        None,
[error]    |                                                        Nil,
[error]    |                                                        Repeated(
[error]    |                                                          List(
[error]    |                                                            Literal(
[error]    |                                                              StringConstant(
[error]    |                                                                "id"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Literal(
[error]    |                                                              StringConstant(
[error]    |                                                                "a"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Literal(
[error]    |                                                              StringConstant(
[error]    |                                                                "b"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Literal(
[error]    |                                                              StringConstant(
[error]    |                                                                "c"
[error]    |                                                              )
[error]    |                                                            )
[error]    |                                                          ),
[error]    |                                                          Inferred()
[error]    |                                                        )
[error]    |                                                      ),
[error]    |                                                      Inferred()
[error]    |                                                    )
[error]    |                                                  )
[error]    |                                                ),
[error]    |                                                List(
[error]    |                                                  Typed(
[error]    |                                                    Inlined(
[error]    |                                                      None,
[error]    |                                                      Nil,
[error]    |                                                      Repeated(
[error]    |                                                        List(
[error]    |                                                          Inlined(
[error]    |                                                            Some(
[error]    |                                                              TypeIdent(
[error]    |                                                                "Lifter"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Nil,
[error]    |                                                            Select(
[error]    |                                                              Select(
[error]    |                                                                Select(
[error]    |                                                                  Select(
[error]    |                                                                    Ident(
[error]    |                                                                      "io"
[error]    |                                                                    ),
[error]    |                                                                    "getquill"
[error]    |                                                                  ),
[error]    |                                                                  "quat"
[error]    |                                                                ),
[error]    |                                                                "Quat"
[error]    |                                                              ),
[error]    |                                                              "Value"
[error]    |                                                            )
[error]    |                                                          ),
[error]    |                                                          Inlined(
[error]    |                                                            Some(
[error]    |                                                              TypeIdent(
[error]    |                                                                "Lifter"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Nil,
[error]    |                                                            Select(
[error]    |                                                              Select(
[error]    |                                                                Select(
[error]    |                                                                  Select(
[error]    |                                                                    Ident(
[error]    |                                                                      "io"
[error]    |                                                                    ),
[error]    |                                                                    "getquill"
[error]    |                                                                  ),
[error]    |                                                                  "quat"
[error]    |                                                                ),
[error]    |                                                                "Quat"
[error]    |                                                              ),
[error]    |                                                              "Value"
[error]    |                                                            )
[error]    |                                                          ),
[error]    |                                                          Inlined(
[error]    |                                                            Some(
[error]    |                                                              TypeIdent(
[error]    |                                                                "Lifter"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Nil,
[error]    |                                                            Select(
[error]    |                                                              Select(
[error]    |                                                                Select(
[error]    |                                                                  Select(
[error]    |                                                                    Ident(
[error]    |                                                                      "io"
[error]    |                                                                    ),
[error]    |                                                                    "getquill"
[error]    |                                                                  ),
[error]    |                                                                  "quat"
[error]    |                                                                ),
[error]    |                                                                "Quat"
[error]    |                                                              ),
[error]    |                                                              "Value"
[error]    |                                                            )
[error]    |                                                          ),
[error]    |                                                          Inlined(
[error]    |                                                            Some(
[error]    |                                                              TypeIdent(
[error]    |                                                                "Lifter"
[error]    |                                                              )
[error]    |                                                            ),
[error]    |                                                            Nil,
[error]    |                                                            Select(
[error]    |                                                              Select(
[error]    |                                                                Select(
[error]    |                                                                  Select(
[error]    |                                                                    Ident(
[error]    |                                                                      "io"
[error]    |                                                                    ),
[error]    |                                                                    "getquill"
[error]    |                                                                  ),
[error]    |                                                                  "quat"
[error]    |                                                                ),
[error]    |                                                                "Quat"
[error]    |                                                              ),
[error]    |                                                              "Value"
[error]    |                                                            )
[error]    |                                                          )
[error]    |                                                        ),
[error]    |                                                        Inferred()
[error]    |                                                      )
[error]    |                                                    ),
[error]    |                                                    Inferred()
[error]    |                                                  )
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              List(
[error]    |                                                Typed(
[error]    |                                                  Inlined(
[error]    |                                                    None,
[error]    |                                                    Nil,
[error]    |                                                    Repeated(Nil, Inferred())
[error]    |                                                  ),
[error]    |                                                  Inferred()
[error]    |                                                )
[error]    |                                              )
[error]    |                                            ),
[error]    |                                            List(
[error]    |                                              Typed(
[error]    |                                                Inlined(
[error]    |                                                  None,
[error]    |                                                  Nil,
[error]    |                                                  Repeated(Nil, Inferred())
[error]    |                                                ),
[error]    |                                                Inferred()
[error]    |                                              )
[error]    |                                            )
[error]    |                                          )
[error]    |                                        )
[error]    |                                      ),
[error]    |                                      Inlined(
[error]    |                                        None,
[error]    |                                        Nil,
[error]    |                                        Inlined(
[error]    |                                          Some(TypeIdent("Lifter")),
[error]    |                                          Nil,
[error]    |                                          Select(Ident("Renameable"), "Fixed")
[error]    |                                        )
[error]    |                                      )
[error]    |                                    )
[error]    |                                  )
[error]    |                                )
[error]    |                              ),
[error]    |                              "asInstanceOf"
[error]    |                            ),
[error]    |                            List(Inferred())
[error]    |                          )
[error]    |                        ),
[error]    |                        Ident("Nil"),
[error]    |                        Ident("Nil")
[error]    |                      )
[error]    |                    ),
[error]    |                    Applied(TypeIdent("Quoted"), List(Inferred()))
[error]    |                  ),
[error]    |                  Applied(
[error]    |                    TypeIdent("Quoted"),
[error]    |                    List(
[error]    |                      Applied(
[error]    |                        TypeIdent("EntityQuery"),
[error]    |                        List(TypeIdent("Record"))
[error]    |                      )
[error]    |                    )
[error]    |                  )
[error]    |                ),
[error]    |                Literal(
[error]    |                  StringConstant("169adb70-5650-4377-ac15-bd6a08321d35")
[error]    |                )
[error]    |              )
[error]    |            ),
[error]    |            "unquote"
[error]    |          ),
[error]    |          Inferred()
[error]    |        ),
[error]    |        "filter"
[error]    |      ),
[error]    |      List(
[error]    |        Block(
[error]    |          List(
[error]    |            DefDef(
[error]    |              "$anonfun",
[error]    |              List(TermParamClause(List(ValDef("_$5", Inferred(), None)))),
[error]    |              Inferred(),
[error]    |              Some(
[error]    |                Apply(
[error]    |                  Select(Select(Ident("_$5"), "id"), "=="),
[error]    |                  List(
[error]    |                    Inlined(
[error]    |                      Some(
[error]    |                        Apply(
[error]    |                          TypeApply(
[error]    |                            Select(Ident("quill"), "lift"),
[error]    |                            List(Inferred())
[error]    |                          ),
[error]    |                          List(Select(Ident("value"), "id"))
[error]    |                        )
[error]    |                      ),
[error]    |                      List(
[error]    |                        ValDef(
[error]    |                          "Context_this",
[error]    |                          Inferred(),
[error]    |                          Some(Ident("quill"))
[error]    |                        )
[error]    |                      ),
[error]    |                      Typed(
[error]    |                        Select(
[error]    |                          Apply(
[error]    |                            TypeApply(
[error]    |                              Select(Ident("EagerPlanter"), "apply"),
[error]    |                              List(Inferred(), Inferred(), Inferred())
[error]    |                            ),
[error]    |                            List(
[error]    |                              Select(Ident("value"), "id"),
[error]    |                              Select(Ident("quill"), "longEncoder"),
[error]    |                              Literal(
[error]    |                                StringConstant(
[error]    |                                  "6804fb7d-4dcb-41d5-bedd-63c6110088f9"
[error]    |                                )
[error]    |                              )
[error]    |                            )
[error]    |                          ),
[error]    |                          "unquote"
[error]    |                        ),
[error]    |                        Inferred()
[error]    |                      )
[error]    |                    )
[error]    |                  )
[error]    |                )
[error]    |              )
[error]    |            )
[error]    |          ),
[error]    |          Closure(Ident("$anonfun"), None)
[error]    |        )
[error]    |      )
[error]    |    ),
[error]    |    "update"
[error]    |  ),
[error]    |  List(
[error]    |    Block(
[error]    |      List(
[error]    |        DefDef(
[error]    |          "$anonfun",
[error]    |          List(TermParamClause(List(ValDef("_$6", Inferred(), None)))),
[error]    |          Inferred(),
[error]    |          Some(
[error]    |            Apply(
[error]    |              TypeApply(
[error]    |                Select(
[error]    |                  Apply(
[error]    |                    TypeApply(Ident("ArrowAssoc"), List(Inferred())),
[error]    |                    List(Select(Ident("_$6"), "a"))
[error]    |                  ),
[error]    |                  "->"
[error]    |                ),
[error]    |                List(Inferred())
[error]    |              ),
[error]    |              List(
[error]    |                Inlined(
[error]    |                  Some(
[error]    |                    Apply(
[error]    |                      TypeApply(
[error]    |                        Select(Ident("quill"), "lift"),
[error]    |                        List(Inferred())
[error]    |                      ),
[error]    |                      List(Select(Ident("value"), "a"))
[error]    |                    )
[error]    |                  ),
[error]    |                  List(
[error]    |                    ValDef("Context_this", Inferred(), Some(Ident("quill")))
[error]    |                  ),
[error]    |                  Typed(
[error]    |                    Select(
[error]    |                      Apply(
[error]    |                        TypeApply(
[error]    |                          Select(Ident("EagerPlanter"), "apply"),
[error]    |                          List(Inferred(), Inferred(), Inferred())
[error]    |                        ),
[error]    |                        List(
[error]    |                          Select(Ident("value"), "a"),
[error]    |                          Select(Ident("quill"), "stringEncoder"),
[error]    |                          Literal(
[error]    |                            StringConstant(
[error]    |                              "2fd449fb-8b87-49b8-961d-0b1613c7f521"
[error]    |                            )
[error]    |                          )
[error]    |                        )
[error]    |                      ),
[error]    |                      "unquote"
[error]    |                    ),
[error]    |                    Inferred()
[error]    |                  )
[error]    |                )
[error]    |              )
[error]    |            )
[error]    |          )
[error]    |        )
[error]    |      ),
[error]    |      Closure(Ident("$anonfun"), None)
[error]    |    ),
[error]    |    Typed(
[error]    |      Apply(
[error]    |        TypeApply(
[error]    |          Select(Ident("Seq"), "apply"),
[error]    |          List(
[error]    |            Applied(
[error]    |              Inferred(),
[error]    |              List(
[error]    |                TypeIdent("Record"),
[error]    |                Applied(Inferred(), List(TypeIdent("Any"), TypeIdent("Any")))
[error]    |              )
[error]    |            )
[error]    |          )
[error]    |        ),
[error]    |        List(
[error]    |          Inlined(
[error]    |            Some(TypeIdent("DeserializeAstInstances$")),
[error]    |            Nil,
[error]    |            TypeApply(
[error]    |              Select(
[error]    |                Inlined(
[error]    |                  None,
[error]    |                  Nil,
[error]    |                  Inlined(
[error]    |                    Some(TypeIdent("Expr$")),
[error]    |                    Nil,
[error]    |                    Apply(
[error]    |                      TypeApply(
[error]    |                        Select(Ident("List"), "apply"),
[error]    |                        List(Inferred())
[error]    |                      ),
[error]    |                      List(
[error]    |                        Typed(
[error]    |                          Inlined(
[error]    |                            None,
[error]    |                            Nil,
[error]    |                            Repeated(
[error]    |                              List(
[error]    |                                Block(
[error]    |                                  List(
[error]    |                                    DefDef(
[error]    |                                      "$anonfun",
[error]    |                                      List(
[error]    |                                        TermParamClause(
[error]    |                                          List(
[error]    |                                            ValDef("_$7", Inferred(), None)
[error]    |                                          )
[error]    |                                        )
[error]    |                                      ),
[error]    |                                      Inferred(),
[error]    |                                      Some(
[error]    |                                        Apply(
[error]    |                                          TypeApply(
[error]    |                                            Select(
[error]    |                                              Apply(
[error]    |                                                TypeApply(
[error]    |                                                  Ident("ArrowAssoc"),
[error]    |                                                  List(Inferred())
[error]    |                                                ),
[error]    |                                                List(
[error]    |                                                  Select(Ident("_$7"), "b")
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              "->"
[error]    |                                            ),
[error]    |                                            List(Inferred())
[error]    |                                          ),
[error]    |                                          List(
[error]    |                                            Inlined(
[error]    |                                              Some(
[error]    |                                                Apply(
[error]    |                                                  TypeApply(
[error]    |                                                    Select(
[error]    |                                                      Ident("quill"),
[error]    |                                                      "lift"
[error]    |                                                    ),
[error]    |                                                    List(Inferred())
[error]    |                                                  ),
[error]    |                                                  List(
[error]    |                                                    Select(
[error]    |                                                      Ident("value"),
[error]    |                                                      "b"
[error]    |                                                    )
[error]    |                                                  )
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              List(
[error]    |                                                ValDef(
[error]    |                                                  "Context_this",
[error]    |                                                  Inferred(),
[error]    |                                                  Some(Ident("quill"))
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              Typed(
[error]    |                                                Select(
[error]    |                                                  Apply(
[error]    |                                                    TypeApply(
[error]    |                                                      Select(
[error]    |                                                        Ident("EagerPlanter"),
[error]    |                                                        "apply"
[error]    |                                                      ),
[error]    |                                                      List(
[error]    |                                                        Inferred(),
[error]    |                                                        Inferred(),
[error]    |                                                        Inferred()
[error]    |                                                      )
[error]    |                                                    ),
[error]    |                                                    List(
[error]    |                                                      Select(
[error]    |                                                        Ident("value"),
[error]    |                                                        "b"
[error]    |                                                      ),
[error]    |                                                      Select(
[error]    |                                                        Ident("quill"),
[error]    |                                                        "stringEncoder"
[error]    |                                                      ),
[error]    |                                                      Literal(
[error]    |                                                        StringConstant(
[error]    |                                                          "450c9f4c-dfe0-458e-90bd-2f49394a5174"
[error]    |                                                        )
[error]    |                                                      )
[error]    |                                                    )
[error]    |                                                  ),
[error]    |                                                  "unquote"
[error]    |                                                ),
[error]    |                                                Inferred()
[error]    |                                              )
[error]    |                                            )
[error]    |                                          )
[error]    |                                        )
[error]    |                                      )
[error]    |                                    )
[error]    |                                  ),
[error]    |                                  Closure(Ident("$anonfun"), None)
[error]    |                                ),
[error]    |                                Block(
[error]    |                                  List(
[error]    |                                    DefDef(
[error]    |                                      "$anonfun",
[error]    |                                      List(
[error]    |                                        TermParamClause(
[error]    |                                          List(
[error]    |                                            ValDef("_$8", Inferred(), None)
[error]    |                                          )
[error]    |                                        )
[error]    |                                      ),
[error]    |                                      Inferred(),
[error]    |                                      Some(
[error]    |                                        Apply(
[error]    |                                          TypeApply(
[error]    |                                            Select(
[error]    |                                              Apply(
[error]    |                                                TypeApply(
[error]    |                                                  Ident("ArrowAssoc"),
[error]    |                                                  List(Inferred())
[error]    |                                                ),
[error]    |                                                List(
[error]    |                                                  Select(Ident("_$8"), "c")
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              "->"
[error]    |                                            ),
[error]    |                                            List(Inferred())
[error]    |                                          ),
[error]    |                                          List(
[error]    |                                            Inlined(
[error]    |                                              Some(
[error]    |                                                Apply(
[error]    |                                                  TypeApply(
[error]    |                                                    Select(
[error]    |                                                      Ident("quill"),
[error]    |                                                      "lift"
[error]    |                                                    ),
[error]    |                                                    List(Inferred())
[error]    |                                                  ),
[error]    |                                                  List(
[error]    |                                                    Select(
[error]    |                                                      Ident("value"),
[error]    |                                                      "c"
[error]    |                                                    )
[error]    |                                                  )
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              List(
[error]    |                                                ValDef(
[error]    |                                                  "Context_this",
[error]    |                                                  Inferred(),
[error]    |                                                  Some(Ident("quill"))
[error]    |                                                )
[error]    |                                              ),
[error]    |                                              Typed(
[error]    |                                                Select(
[error]    |                                                  Apply(
[error]    |                                                    TypeApply(
[error]    |                                                      Select(
[error]    |                                                        Ident("EagerPlanter"),
[error]    |                                                        "apply"
[error]    |                                                      ),
[error]    |                                                      List(
[error]    |                                                        Inferred(),
[error]    |                                                        Inferred(),
[error]    |                                                        Inferred()
[error]    |                                                      )
[error]    |                                                    ),
[error]    |                                                    List(
[error]    |                                                      Select(
[error]    |                                                        Ident("value"),
[error]    |                                                        "c"
[error]    |                                                      ),
[error]    |                                                      Select(
[error]    |                                                        Ident("quill"),
[error]    |                                                        "stringEncoder"
[error]    |                                                      ),
[error]    |                                                      Literal(
[error]    |                                                        StringConstant(
[error]    |                                                          "7f3eea14-6f58-4a37-9151-0de8e0c94fd6"
[error]    |                                                        )
[error]    |                                                      )
[error]    |                                                    )
[error]    |                                                  ),
[error]    |                                                  "unquote"
[error]    |                                                ),
[error]    |                                                Inferred()
[error]    |                                              )
[error]    |                                            )
[error]    |                                          )
[error]    |                                        )
[error]    |                                      )
[error]    |                                    )
[error]    |                                  ),
[error]    |                                  Closure(Ident("$anonfun"), None)
[error]    |                                )
[error]    |                              ),
[error]    |                              Inferred()
[error]    |                            )
[error]    |                          ),
[error]    |                          Inferred()
[error]    |                        )
[error]    |                      )
[error]    |                    )
[error]    |                  )
[error]    |                ),
[error]    |                "asInstanceOf"
[error]    |              ),
[error]    |              List(Inferred())
[error]    |            )
[error]    |          )
[error]    |        )
[error]    |      ),
[error]    |      Inferred()
[error]    |    )
[error]    |  )
[error]    |)
[error]    |==== Stacktrace ===
[error]    |  java.base/java.lang.Thread.getStackTrace(Thread.java:2450)
[error]    |  io.getquill.parser.engine.failParse$.apply(failParse.scala:29)
[error]    |  io.getquill.parser.engine.failParse$.apply(failParse.scala:13)
[error]    |  io.getquill.parser.engine.Parser.error(Parser.scala:10)
[error]    |  io.getquill.parser.engine.Parser.error$(Parser.scala:7)
[error]    |  io.getquill.parser.engine.ParserChain$$anon$1.error(ParserChain.scala:15)
[error]    |  io.getquill.parser.engine.Parser.apply$$anonfun$1(Parser.scala:9)
[error]    |  scala.Option.getOrElse(Option.scala:201)
[error]    |  io.getquill.parser.engine.Parser.apply(Parser.scala:9)
[error]    |  io.getquill.parser.engine.Parser.apply$(Parser.scala:7)
[error]    |  io.getquill.parser.engine.ParserChain$$anon$1.apply(ParserChain.scala:15)
[error]    |  io.getquill.parser.ParserLibrary$ReadyParser.apply(Parser.scala:107)
[error]    |  io.getquill.context.QuoteMacro$.apply(QuoteMacro.scala:135)
[error]    |  java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[error]    |  java.base/java.lang.reflect.Method.invoke(Method.java:580)
[error]    |  dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall$$anonfun$1(Interpreter.scala:172)
[error]    |  dotty.tools.dotc.quoted.Interpreter.stopIfRuntimeException(Interpreter.scala:229)
[error]    |  dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall(Interpreter.scala:172)
[error]    |  dotty.tools.dotc.quoted.Interpreter.interpretTree(Interpreter.scala:80)
[error]    |  dotty.tools.dotc.transform.Splicer$SpliceInterpreter.interpretTree(Splicer.scala:258)
[error]    |  dotty.tools.dotc.quoted.Interpreter.interpretTree$$anonfun$2(Interpreter.scala:99)
[error]    |  dotty.tools.dotc.transform.Splicer$.$anonfun$2(Splicer.scala:60)
[error]    |  scala.Option.fold(Option.scala:263)
[error]    |  dotty.tools.dotc.transform.Splicer$.splice(Splicer.scala:60)
[error]    |  dotty.tools.dotc.inlines.Inliner.dotty$tools$dotc$inlines$Inliner$$expandMacro(Inliner.scala:1048)
[error]    |  dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSplice(Inliner.scala:839)
[error]    |  dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3092)
[error]    |  dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112)
[error]    |  dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:146)
[error]    |  dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:915)
[error]    |  dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184)
[error]    |  dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188)
[error]    |  dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:65)
[error]    |  dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3053)
[error]    |  dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3112)
[error]    |  dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:146)
[error]    |  dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:915)
[error]    |  dotty.tools.dotc.typer.Typer.typed(Typer.scala:3184)
[error]    |  dotty.tools.dotc.typer.Typer.typed(Typer.scala:3181)
[error]    |  dotty.tools.dotc.typer.Typer.typed(Typer.scala:3188)
[error]    |  dotty.tools.dotc.inlines.Inliner.inlined(Inliner.scala:681)
[error]    |  dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:444)
[error]    |  dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:152)
[error]    |  dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:95)
[error]    |  dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1605)
[error]    |  scala.collection.immutable.List.mapConserve(List.scala:472)
[error]    |  dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1605)
[error]    |  dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1504)
[error]    |  dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error]    |  dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:93)
[error] 31 |          _.a -> lift(value.a),
[error] 32 |          Seq[Record => (Any, Any)](
[error] 33 |            _.b -> lift(value.b),
[error] 34 |            _.c -> lift(value.c))*

Second Error

[error] -- Error: /Users/jmp/code/learn/scala3-sample/lib/src/test/scala/com/saldubatech/Example.scala:26:37 
[error]  26 |  def badUpdate(value: Record) = run {
[error]     |                                 ^
[error]     |Exception occurred while executing macro expansion.
[error]     |scala.MatchError: EmptyTree (of class dotty.tools.dotc.ast.Trees$EmptyTree)
[error]     |   at scala.quoted.runtime.impl.printers.Extractors$ExtractorsPrinter.visitTree(Extractors.scala:179)
[error]     |   at scala.quoted.runtime.impl.printers.Extractors$ExtractorsPrinter$TreeOps.$plus$eq(Extractors.scala:286)
[error]     |   at scala.quoted.runtime.impl.printers.Extractors$ExtractorsPrinter.visitTree(Extractors.scala:179)
[error]     |   at scala.quoted.runtime.impl.printers.Extractors$.showTree(Extractors.scala:9)
[error]     |   at scala.quoted.runtime.impl.QuotesImpl$$anon$14.show(QuotesImpl.scala:3108)
[error]     |   at scala.quoted.runtime.impl.QuotesImpl$$anon$14.show(QuotesImpl.scala:3107)
[error]     |   at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExpr(QuotesImpl.scala:111)
[error]     |   at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExpr(QuotesImpl.scala:106)
[error]     |   at io.getquill.context.StaticTranslationMacro$.apply(StaticTranslationMacro.scala:230)
[error]     |   at io.getquill.context.QueryExecution$RunQuery.applyAction(QueryExecution.scala:271)
[error]     |   at io.getquill.context.QueryExecution$RunQuery.apply(QueryExecution.scala:215)
[error]     |   at io.getquill.context.QueryExecution$.applyImpl(QueryExecution.scala:422)
[error]     |
[error]  27 |    quote {
[error]  28 |      query
[error]  29 |        .filter(_.id == lift(value.id))
[error]  30 |        .update(
[error]  31 |          _.a -> lift(value.a),
[error]  32 |          Seq[Record => (Any, Any)](
[error]  33 |            _.b -> lift(value.b),
[error]  34 |            _.c -> lift(value.c))*
[error]  35 |        )
[error]  36 |    }
[error]  37 |  }
[error]     |---------------------------------------------------------------------------
[error]     |Inline stack trace
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from QueryExecution.scala:404
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from QueryExecution.scala:404
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from QueryExecution.scala:404
[error]      ---------------------------------------------------------------------------

Steps to reproduce the behavior

This self-contained file exhibits the problem with the obvious sbt dependencies added.

The goodUpdate method compiles, the badUpdate method does not in violation of the Scala calling convention with Varargs.

import io.getquill._
import io.getquill.jdbczio.Quill

class Example(using quill: Quill.Postgres[Literal]) {
  import quill._
  case class Record(val id: Long, val a: String, val b: String, val c: String)
  
  inline def query: Quoted[EntityQuery[Record]] = quote {
    querySchema[Record]("records")
  }

  def goodUpdate(value: Record) = run {
    quote {
      query
        .filter(_.id == lift(value.id))
        .update(
          _.a -> lift(value.a),
          _.b -> lift(value.b),
          _.c -> lift(value.c)
        )

    }
  }

  def badUpdate(value: Record) = run {
    quote {
      query
        .filter(_.id == lift(value.id))
        .update(
          _.a -> lift(value.a),
          Seq[Record => (Any, Any)](
            _.b -> lift(value.b),
            _.c -> lift(value.c))*
        )

    }
  }

}

Workaround

The obvious workaround is to use the explicit varargs construction, but this forces a lot of code repetition for flexible update methods and similar constructs.

It is understandable that this would be a problem for static compilation of SQL, but the macro expansion should fall back to dynamic query execution in those cases (as it does in other situations)

As an added comment, the same problem is also present in the querySchema call, although the need for "composability" is much less in that case.

@getquill/maintainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant