"Could not map row" on join with nested query
Environment:
- Scala 2.9.2
- Squeryl just pulled from github on 24-nov 8:00 UTC (last commit: 169489e37b27203d57be6727fe8f164470653485)
Steps to reproduce:
Add code to test InnerJoin in NestedLeftOuterJoin test to:
- Insert an additional A (without a corresponding B in the DB)
- Read that additional row from the query in checkLeftJoinQuery
(My whole test is attached for reference)
Run tests.
Expected result
Tests pass
Actual result
[info] - InnerJoin *** FAILED *** [info] java.lang.RuntimeException: could not map row : [info] ResultSetRow:[#1->a two:String,#2->2:Integer,#3->null:String,#4->null:Integer,#5->null:Integer] [info] with mapper : [info] 'ResultSetMapper:4dc4c6($(3->B.name:java.lang.String),$(4->B.aId:java.lang.Integer),$(5->B.id:java.lang.Integer))--* [info] at org.squeryl.internals.ResultSetMapper.map(ResultSetMapper.scala:237) [info] at org.squeryl.View.give(View.scala:89) [info] at org.squeryl.dsl.AbstractQuery$SubQueryable.give(AbstractQuery.scala:283) [info] at org.squeryl.dsl.boilerplate.Query1.invokeYield(Query1.scala:32) [info] at org.squeryl.dsl.AbstractQuery.give(AbstractQuery.scala:42) [info] at org.squeryl.dsl.AbstractQuery$SubQueryable.give(AbstractQuery.scala:275) [info] at org.squeryl.dsl.boilerplate.Query2.invokeYield(Query1.scala:50) [info] at org.squeryl.dsl.AbstractQuery.give(AbstractQuery.scala:42) [info] at org.squeryl.dsl.AbstractQuery$$anon$1.next(AbstractQuery.scala:213) [info] at org.squeryl.internals.IteratorConcatenation.next(Utils.scala:127) [info] ... [info] Cause: java.lang.RuntimeException: B.aId:java.lang.Integer was invoked with value 'null' of type null on object of type org.squeryl.test.B [info] java.lang.IllegalArgumentException: Can not set final int field org.squeryl.test.B.aId to null value [info] at org.squeryl.internals.Utils$.throwError(Utils.scala:95) [info] at org.squeryl.internals.FieldMetaData.set(FieldMetaData.scala:342) [info] at org.squeryl.internals.FieldMetaData.setFromResultSet(FieldMetaData.scala:297) [info] at org.squeryl.internals.ColumnToFieldMapper.map(ResultSetMapper.scala:112) [info] at org.squeryl.internals.ResultSetMapper$$anonfun$map$2.apply(ResultSetMapper.scala:233) [info] at org.squeryl.internals.ResultSetMapper$$anonfun$map$2.apply(ResultSetMapper.scala:232) [info] at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60) [info] at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47) [info] at org.squeryl.internals.ResultSetMapper.map(ResultSetMapper.scala:232) [info] at org.squeryl.View.give(View.scala:89) [info] ...
Notes
I found a reference to what I am pretty sure is this same problem (without solution or steps to reproduce) in https://groups.google.com/d/topic/squeryl/Y2DA96gQdqg/discussion -- so it's a pretty old one.
Leave a comment
file:dtbYLYnHur4PtQacwqjQYw
Test case
Test case
on 2012-11-24 09:11 *
By jordi.salvat.i.alabart
WORKAROUND: Both in the referenced discussion and in my particular case, this can be worked around by "flattening" the query -- that is: joining in the original table instead of the nested query and including the where clauses of the nested query in the where clause of the join.