score:0
The getOrElse(null)
is causing your problem. This is because you're calling getOrElse
on an Option[Float]
. However null
in Scala cannot be assigned to a value type like Float
. From the scaladoc:
Null is a subtype of all reference types; its only instance is the null reference. Since Null is not a subtype of value types, null is not a member of any such type. For instance, it is not possible to assign null to a variable of type scala.Int.
The same statement applies to Float
. Since null
and Float
do not have a common super-type (other than Any
), Scala infers the caller.map(_._1).getOrElse(null)
as Any
instead Float
. This was allowed in Play 2.2.x, however in 2.3.x, Any
is no longer allowed to be passed as a parameter because it is not type safe.
The solution? Just remove the getOrElse(null)
s and you're good to go. caller.map(_._1)
is an Option[Float]
which Anorm knows how to handle whether it's empty or not. In general, using null
in Scala is bad practice. If you see yourself calling getOrElse(null)
, you should ask yourself if perhaps there's a better way to handle it safely.
score:1
Try
val ps = Seq[anorm.ParameterValue](yourParameter1,yourParameter2) // Seq[ParameterValue]
SQL("SELECT * FROM test WHERE a={a} b={b}").
on('a -> ps(0), 'b -> ps(1))
You are using parameter of Any
(or someother) type but the doc says to use anorm.ParameterValue
type
score:1
I would suggest to first try val p: ParameterValue = caller
.
I think the issue is more that there is no specific parameter conversion for Tuple2[Float,Float]
(btw (Float, Float)
).
Before Anorm 2.3, unsafe conversion was using .toString
(which can lead to a lot of issue).
The better is to convert the tuple to a formatted string, either before passing it as parameter or by adding a custom parameter conversion.
(Anorm doc indicates type safety issues, and how to implement conversion)
Source: stackoverflow.com
Related Query
- Migration play from 2.2 to 2.3: No implicit view available from Any
- No implicit view available from fastparse.P[Any] => fastparse.P[Unit]
- json4s, "no implicit view available from List of case class to JValue" when attempting to combine
- No implicit view available from K => Ordered[K]. Error occurred in an application involving default arguments
- Implicit Conversion from Any to Dynamic
- Play 2.5 Migration Error: Custom Action with BodyParser: could not find implicit value for parameter mat: akka.stream.Materializer
- Java Play akka project migration from jdk8 to jdk11
- No Implicit View Available
- Play 2.5 upgrade error: CompletionException - There is no HTTP Context available from here
- No implicit view available for partially applied method
- Casbah: No implicit view available error
- How to view images from local directories in play scala project
- MappedEnum - No implicit view available
- How to define multiple values in routes from a view template in Play 2
- Is there any way to look up the controller and method names from a request in Play Framework 2.0
- In scala, are there any condition where implicit view won't be able to propagate to other implicit function?
- Scala, PlayFramework - No implicit Format available for Any
- Adding a parameter to Implicit Reads building a case class from JSON with Play
- No implicit view avaliable from A => Ordered[A] while using default values
- Play Framework - migration from version 2.3.x to 2.4.1: how to determine whether a JSON value is JsUndefined
- getting Suspicious application of an implicit view when converting from Option(lang.Long) to Long
- Scala Play No implicit format for Seq[Option[models.ProcessStepTemplatesModel]] available
- making an implicit available within a play action
- How to pass Request Header from Main view to Partial View in Play framework
- Passing data from controller to view in scala / play framework
- Play Framework compilation error when passing List object from controller to view
- How do I include parent template from any directory in Play Framework
- Migration from Play Websocket to Akka HTTP Websocket
- Play framework 2: implicit values in view
- Upload file after migration from play 2.1 to 2.6 doesn't work anymore
More Query from same tag
- Implicit parameter "chaining" for DSL
- Scala repeat Array
- Type MisMatch Require Tuple2, but Map Found
- implicits for objects in Scala
- Refer generic class by name
- Updating an RDD based on value of the other RDD
- How to resolve a list of futures in Scala
- How to push Spark dataframe to Sql Server table when set_identity is off?
- Create a var/val of singleton class in scala
- Gatling 2 : How to change directory location of the scala classes
- Akka-actor java.lang.NoClassDefFoundError: akka/actor/CoordinatedShutdown$$anonfun$totalTimeout
- The differences between using `val` and `def` for function definition in Scala REPL?
- How to conditionally include a Hibernate annotation?
- Spark Join based on nearest Date
- how to join two datasets by key in scala spark
- Stubbing SOAP requests in Scala
- Unexpected behavior with scala and URLClassLoader
- going to specific path in scala using scala.sys.process
- How to Enable HSTS in Play framework 2.3.x using scala code?
- Why zip does not work with match case in Scala?
- Creating a more specific implicit using a structural type with Scala
- Can you run test suites more than once in ScalaTest?
- Can sbt-native-packager package many server applications in one deb package?
- Get Future objects from Future Options in Scala
- Spark + Intellij + Azure - output to screen
- Possible to find parameter type methods return type in Scala where parameter is a primitive type?
- What is the equivalent of Scala's map case in Python
- Dynamic properties in Scala
- How can a mill task update environment variables so that later running tasks will see the updated value?
- One-liner loop using only recursion in scala