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

ClassCastException using distinctOn #2135

Open
JustinPihony opened this issue Oct 24, 2020 · 0 comments
Open

ClassCastException using distinctOn #2135

JustinPihony opened this issue Oct 24, 2020 · 0 comments

Comments

@JustinPihony
Copy link

DESCRIPTION:

Upon upgrading to Slick 3.3.3 in order to get the #2097 fix for a bug with distinctOn described in #1340 - another case was observed when distinctOn is used for multiple columns (with MySQL) that's now failing with a ClassCastException.:

STEPS TO REPRODUCE:

A sample of the query is below, however the error is transient and

/* Composed from various joins and filters. */
def query: Query[(ClientTable, UserTable, OrganizationUserTable, PhoneTable), (ClientRow, UserRow[Value], OrganizationUserRow, PhoneRow[Value]), Seq] = ???
query
  .map { case (client, user, _, phone) => (client, user, phone) }
  .distinctOn { case (client, user, phone) => (client.id, user.userId, phone.id) }

(In scope are imports from an extension of slick.jdbc.MySQLProfile that provides mappers for various ID wrapper types)

EXPECTED RESULT:

Execute distinctOn without exception

ACTUAL RESULT:

java.lang.ClassCastException: class classpath.to.backend.persistence.UserId cannot be cast to class classpath.to.backend.persistence.ClientId (classpath.to.backend.persistence.UserId and classpath.to.backend.persistence.ClientId are in unnamed module of loader sbt.internal.LayeredClassLoader @9bb579c
[info]  at scala.Function4.$anonfun$tupled$1(Function4.scala:40)
[info]  at slick.relational.TypeMappingResultConverter.read(ResultConverter.scala:134)
[info]  at slick.relational.ProductResultConverter.read(ResultConverter.scala:54)
[info]  at slick.relational.ProductResultConverter.read(ResultConverter.scala:44)
[info]  at slick.jdbc.JdbcInvokerComponent$QueryInvokerImpl.extractValue(JdbcInvokerComponent.scala:36)
[info]  at slick.jdbc.StatementInvoker$$anon$2.extractValue(StatementInvoker.scala:67)
[info]  at slick.jdbc.PositionedResultIterator.fetchNext(PositionedResult.scala:176)
[info]  at slick.util.ReadAheadIterator.update(ReadAheadIterator.scala:28)
[info]  at slick.util.ReadAheadIterator.hasNext(ReadAheadIterator.scala:34)
[info]  at slick.util.ReadAheadIterator.hasNext$(ReadAheadIterator.scala:33)
[info]  at slick.jdbc.PositionedResultIterator.hasNext(PositionedResult.scala:167)
[info]  at slick.jdbc.StreamingInvokerAction.emitStream(StreamingInvokerAction.scala:31)
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