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

Distinct with Query Schema Crashes #1565

Closed
deusaquilus opened this issue Aug 15, 2019 · 0 comments · Fixed by #1613
Closed

Distinct with Query Schema Crashes #1565

deusaquilus opened this issue Aug 15, 2019 · 0 comments · Fixed by #1613
Labels

Comments

@deusaquilus
Copy link
Collaborator

deusaquilus commented Aug 15, 2019

Version: (e.g. 3.4.0-SNAPSHOT)
Module: (e.g. quill-sql)
Database: (e.g. ALL)

Multiple distinct does not work with query schemas:

case class SimpleEnt(a: Int, b: String)
case class SimpleEnt2(aa: Int, bb: String)

val qschem = quote {
  querySchema[SimpleEnt]("CustomEnt", _.a -> "field_a")
}

val q = quote {
  qschem.map(e => SimpleEnt(e.a + 1, e.b))
    .distinct
    .map(e => SimpleEnt2(e.a + 2, e.b))
    .distinct
}
println(run(q).string)

The following error occurs:

cmd3.sc:14: exception during macro expansion: 
java.util.NoSuchElementException: key not found: field_a
	at scala.collection.MapLike$class.default(MapLike.scala:228)
	at scala.collection.AbstractMap.default(Map.scala:59)
	at scala.collection.MapLike$class.apply(MapLike.scala:141)
	at scala.collection.AbstractMap.apply(Map.scala:59)

Technically, it goes without saying... but the problem also happens with schemaMeta:

implicit val qs = schemaMeta[SimpleEnt]("CustomEnt", _.a -> "field_a")

val q = quote {
  query[SimpleEnt].map(e => SimpleEnt(e.a + 1, e.b))
    .distinct
    .map(e => SimpleEnt2(e.a + 2, e.b))
    .distinct
}
println(run(q).string)

@getquill/maintainers

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

Successfully merging a pull request may close this issue.

1 participant