Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case class default parameters #274

Open
cranst0n opened this issue Mar 1, 2016 · 3 comments
Open

case class default parameters #274

cranst0n opened this issue Mar 1, 2016 · 3 comments
Milestone

Comments

@cranst0n
Copy link

cranst0n commented Mar 1, 2016

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.

@tpolecat
Copy link
Owner

tpolecat commented Mar 2, 2016

Hi, thanks. I'll take a look at this for the next version.

@tpolecat tpolecat modified the milestone: Backlog Nov 17, 2016
@LMnet
Copy link
Contributor

LMnet commented Nov 8, 2019

In case if someone needs a temporary solution: https://gist.github.com/LMnet/2be88b61078a5cc1416312850093166c

@halfhp
Copy link

halfhp commented Jun 13, 2022

any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants