doobie
doobie copied to clipboard
case class default parameters
Given:
// AnalysisSpec
case class Foo(bar: Long, baz: Int, shenanigans: Array[Byte] = Array[Byte]())
val q0 = sql"""select f.bar, f.baz, f.shenanigans from Foo f""".query[Foo]
val q1 = sql"""select f.bar, f.baz from Foo f""".query[Foo]
"Example" should {
"have typechecked queries" in {
checkOutput(q0)
checkOutput(q1)
}
}
q1
will not type check due to the default parameter for shenanigans
:
[info] Example should
[info] have typechecked queries
[info] Query0[FooSpec.Foo] defined at FooSpec.scala:33
[info] select f.bar, f.baz, f.shenanigans from Foo f
[info] + SQL Compiles and Typechecks
[info] + C01 bar BIGINT (BIGINT) NOT NULL → Long
[info] + C02 baz INTEGER (INT) NOT NULL → Int
[info] + C03 shenanigans LONGVARBINARY (MEDIUMBLOB) NOT NULL → Array[Byte]
[info] Query0[FooSpec.Foo] defined at FooSpec.scala:34
[info] select f.bar, f.baz from Foo f
[info] + SQL Compiles and Typechecks
[info] + C01 bar BIGINT (BIGINT) NOT NULL → Long
[info] + C02 baz INTEGER (INT) NOT NULL → Int
[error] x C03 → Array[Byte]
[error] x Too few columns are selected, which will result in a runtime failure. Add a
[error] column or remove mapped Array[Byte] from the result type. (DoobieEventComponentSpec.scala:34)
@milessabin reports that shapeless 2.3.0 supports default parameters so this will hopefully be solved when the dependency is updated.
Hi, thanks. I'll take a look at this for the next version.
In case if someone needs a temporary solution: https://gist.github.com/LMnet/2be88b61078a5cc1416312850093166c
any update on this?