I am trying to write some code to test a database model. Both the test framework and the database framework use the “===” operator, and the test framework’s is being given preference. How can I explicitly use one method or the other?
Example:
import org.scalatest.FunSuite
class TestDBModels extends FunSuite{
test("Test DoublePropertyEntry with a few new values") {
Schemas.doubleProperties.deleteWhere(p => (p.id === p.id)))
}
}
Error:
type mismatch;
found : Option[String]
required: org.squeryl.dsl.ast.LogicalBoolean
Schemas.doubleProperties.deleteWhere(p => (p.===(p.id, p.id)))
You have a number of options. The first and easiest is to use an explicit method call instead of the implicit conversion. For example, to explicitly use the scalatest ===:
If this is too long, you could shorten the name:
convertToEqualizer is the implicit conversion method for scalatest. One other option is to override convertToEqualizer as a non-implicit method:
This stops this particular implicit conversion happening. See the scalatest documentation for Assertions object and the same question on the scalatest-users mailing list.