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 caused by empty inSet on Option column #771

Closed
ijuma opened this issue Apr 22, 2014 · 5 comments
Closed

ClassCastException caused by empty inSet on Option column #771

ijuma opened this issue Apr 22, 2014 · 5 comments
Assignees
Milestone

Comments

@ijuma
Copy link
Contributor

ijuma commented Apr 22, 2014

This is a regression in Slick 2.1.0-M1.

Here's a commit that updates a test to include the failing case:

https://github.com/ijuma/slick/commit/911ca04468959278457bd544cbb40e4eee742bd0

The stacktrace:

java.lang.Boolean cannot be cast to scala.Option
java.lang.ClassCastException: java.lang.Boolean cannot be cast to scala.Option
    at scala.slick.driver.JdbcStatementBuilderComponent$class.valueToSQLLiteral(JdbcStatementBuilderComponent.scala:36)
    at scala.slick.driver.H2Driver$.valueToSQLLiteral(H2Driver.scala:62)
    at scala.slick.driver.JdbcStatementBuilderComponent$QueryBuilder.expr(JdbcStatementBuilderComponent.scala:205)
    at scala.slick.driver.H2Driver$QueryBuilder.scala$slick$driver$JdbcStatementBuilderComponent$OracleStyleRowNum$$super$expr(H2Driver.scala:44)
    at scala.slick.driver.JdbcStatementBuilderComponent$OracleStyleRowNum$class.expr(JdbcStatementBuilderComponent.scala:436)
    at scala.slick.driver.H2Driver$QueryBuilder.expr(H2Driver.scala:50)
    at scala.slick.driver.JdbcStatementBuilderComponent$QueryBuilder$$anonfun$buildWhereClause$1.apply$mcV$sp(JdbcStatementBuilderComponent.scala:136)
    at scala.slick.driver.JdbcStatementBuilderComponent$QueryBuilder.building(JdbcStatementBuilderComponent.scala:71)
    at scala.slick.driver.JdbcStatementBuilderComponent$QueryBuilder.buildWhereClause(JdbcStatementBuilderComponent.scala:133)
    at scala.slick.driver.JdbcStatementBuilderComponent$QueryBuilder.buildComprehension(JdbcStatementBuilderComponent.scala:92)
    at scala.slick.driver.JdbcStatementBuilderComponent$QueryBuilder.buildSelect(JdbcStatementBuilderComponent.scala:62)
    at scala.slick.driver.JdbcProfile$$anonfun$queryCompiler$1.apply(JdbcProfile.scala:30)
    at scala.slick.driver.JdbcProfile$$anonfun$queryCompiler$1.apply(JdbcProfile.scala:30)
    at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcCodeGen$$anonfun$apply$2.apply(JdbcMappingCompilerComponent.scala:64)
    at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcCodeGen$$anonfun$apply$2.apply(JdbcMappingCompilerComponent.scala:63)
    at scala.slick.ast.ClientSideOp$.mapResultSetMapping(ClientSideOp.scala:22)
    at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcCodeGen.apply(JdbcMappingCompilerComponent.scala:63)
    at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcCodeGen$$anonfun$apply$1.apply(JdbcMappingCompilerComponent.scala:60)
    at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcCodeGen$$anonfun$apply$1.apply(JdbcMappingCompilerComponent.scala:60)
    at scala.slick.compiler.CompilerState.map(QueryCompiler.scala:176)
    at scala.slick.jdbc.JdbcMappingCompilerComponent$JdbcCodeGen.apply(JdbcMappingCompilerComponent.scala:60)
    at scala.slick.compiler.QueryCompiler$$anonfun$runPhase$1.apply(QueryCompiler.scala:79)
    at scala.slick.compiler.QueryCompiler$$anonfun$runPhase$1.apply(QueryCompiler.scala:78)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
    at scala.slick.ast.SymbolNamer.use(Symbol.scala:92)
    at scala.slick.compiler.QueryCompiler.runPhase(QueryCompiler.scala:78)
    at scala.slick.compiler.QueryCompiler$$anonfun$runPhases$4.apply(QueryCompiler.scala:75)
    at scala.slick.compiler.QueryCompiler$$anonfun$runPhases$4.apply(QueryCompiler.scala:75)
    at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
    at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
    at scala.collection.Iterator$class.foreach(Iterator.scala:727)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:144)
    at scala.collection.AbstractIterator.foldLeft(Iterator.scala:1157)
    at scala.slick.compiler.QueryCompiler.runPhases(QueryCompiler.scala:75)
    at scala.slick.compiler.QueryCompiler.run(QueryCompiler.scala:53)
    at scala.slick.compiler.QueryCompiler.run(QueryCompiler.scala:47)
    at scala.slick.profile.BasicProfile$Implicits$class.queryToQueryExecutor(BasicProfile.scala:51)
@cvogt cvogt added bug labels Apr 22, 2014
@cvogt cvogt added this to the 2.1-M2 milestone Apr 22, 2014
@cvogt
Copy link
Member

cvogt commented Apr 22, 2014

here is the test from @ijuma's commit:

users.filter(_.last inSetBind Seq()).map(u => (u.first, u.last)).run

added to the end of MainTest

@szeiger
Copy link
Member

szeiger commented Apr 22, 2014

Looks unrelated to the recent changes with Option handling moving from JdbcType into ResultConverter. It's actually a bug in the hoistClientOps phase. This needs to be double-checked against 2.0.0 and 2.0.1 to make sure the bug is not there (I would expect it to be). Working on a fix for 2.1.

@ijuma
Copy link
Contributor Author

ijuma commented Apr 22, 2014

Our test passes with Slick 2.0.1 and fails with 2.1.0-M1. So something changed that caused this to be triggered.

szeiger added a commit that referenced this issue Apr 22, 2014
Patching the types was wrong and only worked for view columns, where the
wrong type is equivalent to the correct one, and for computed values,
where the wrong type is not used at all. It failed for LiteralNodes. The
solution is to leave OptionApply intact in hoistClientOps and ignore it
in QueryBuilder.

Test in MainTest.test. Fixes issue #771.
@szeiger
Copy link
Member

szeiger commented Apr 22, 2014

The bug in hoistClientOps is the same in 2.0 but it's cancelled out by another bug: https://github.com/slick/slick/blob/2.0/src/main/scala/scala/slick/driver/JdbcStatementBuilderComponent.scala#L192 - Notice that this looks at tpe (the special statically known type of a TypedNode), not nodeType (the dynamically computed type), so it still sees the original (correct) type and not the wrong one produced by hoistClientOps.

@szeiger szeiger closed this as completed Apr 22, 2014
@ijuma
Copy link
Contributor Author

ijuma commented Apr 22, 2014

Got to love bugs that cancel other bugs. :)

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

No branches or pull requests

3 participants