Skip to content

Instantly share code, notes, and snippets.

@okapies
Created November 18, 2017 11:06
Show Gist options
  • Save okapies/93a0f7455fd187dfd7bf1d096696e205 to your computer and use it in GitHub Desktop.
Save okapies/93a0f7455fd187dfd7bf1d096696e205 to your computer and use it in GitHub Desktop.
Problem in filtering an optional column in Slick 3.2
// ref. https://gist.github.com/cvogt/9193220
// See the example in http://slick.lightbend.com/doc/3.2.1/gettingstarted.html
// I add an optional `buyer` column to Suppliers:
class Suppliers(tag: Tag) extends Table[(Int, String, String, String, String, String, Option[String])](tag, "SUPPLIERS") {
...
def buyer = column[Option[String]]("BUYER")
...
}
// Change `=== Option(...)` to `=== Some(...)` cause the following compile error:
suppliers.filter(_.buyer === Option("Martin"))
// [error] DBQueries.scala:32:36: type mismatch;
// [error] found : Some[String]
// [error] required: slick.lifted.Rep[?]
// [error] suppliers.filter(_.buyer === Some("Martin"))
// [error] ^
// [error] DBQueries.scala:32:19: ambiguous implicit values:
// [error] both value BooleanCanBeQueryCondition in object CanBeQueryCondition of type => slick.lifted.CanBeQueryCondition[Boolean]
// [error] and value BooleanOptionColumnCanBeQueryCondition in object CanBeQueryCondition of type => slick.lifted.CanBeQueryCondition[slick.lifted.Rep[Option[Boolean]]]
// [error] match expected type slick.lifted.CanBeQueryCondition[Nothing]
// [error] suppliers.filter(_.buyer === Some("Martin"))
// [error] ^
// [error] two errors found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment