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

Type aliases in nested generic Embedded case classes causes query splicing to fail #249

Open
arturaz opened this issue Mar 8, 2023 · 0 comments

Comments

@arturaz
Copy link
Contributor

arturaz commented Mar 8, 2023

Version: 4.6.0.1
Module: quill-sql

Steps to reproduce the behavior

import io.getquill._

case class Loadout[+W](weapons: W) extends Embedded
case class LoadoutSetsA[A](set1: A, set2: A) extends Embedded

// // This works
// case class Inventory(loadoutSets: LoadoutSetsA[Loadout[Int]])

// This breaks with:
// Query splicing failed due to error: io.getquill.quotation.QuatException: Quat at /loadoutSets is not
// a product but we need to go into ./ and write renames: [(weapons,set1)]
//	at io.getquill.quotation.QuatException$.apply(QuatException.scala:8)
//	at io.getquill.quat.QuatOps$.renameQuatAtPathRecurse$1(QuatOps.scala:26)
//	at io.getquill.quat.QuatOps$.renameQuatAtPathRecurse$1(QuatOps.scala:28)
//	at io.getquill.quat.QuatOps$.renameQuatAtPath(QuatOps.scala:42)
//  ...
type LoadoutFoo = Loadout[Int]
case class Inventory(loadoutSets: LoadoutSetsA[LoadoutFoo])


class MyContext extends SqlMirrorContext(MirrorSqlDialect, Literal)


inline def inventory = 
  querySchema[Inventory](
    "inventory",
    _.loadoutSets.set1.weapons -> "set1",
    _.loadoutSets.set2.weapons -> "set2",
  )

val ctx = new MyContext()
import ctx.*
println(ctx.run(inventory))

https://scastie.scala-lang.org/BON7uUaZTr29lgXAMNo8Rw

Workaround

Do not use type aliases in table definitions.

@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