Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Ignore structure inside Option field #443

Open
gregorath opened this issue Jun 1, 2023 · 0 comments
Open

Ignore structure inside Option field #443

gregorath opened this issue Jun 1, 2023 · 0 comments

Comments

@gregorath
Copy link

gregorath commented Jun 1, 2023

Hello, I was trying to compare two case classes with nested optional structures but it seems that it doesn't work.

For example the following

import com.softwaremill.diffx.Diff.Typeclass
import com.softwaremill.diffx.*

case class Test(id: Int)
case class TestWrap(id: Test)
case class TestWrapWrap(id: Option[TestWrap])

val t1 = TestWrapWrap(Option(TestWrap(Test(1))))
val t2 = TestWrapWrap(Option(TestWrap(Test(2))))

given Typeclass[Test] = Diff.derived
given Typeclass[TestWrap] = Diff.derived
given Typeclass[TestWrapWrap] = Diff.derived

val diff = Diff[TestWrapWrap].ignore(_.id.each.id)
val diffResult = diff(t1, t2)

should pass but actually fails with:

TestWrapWrap(
            	id: TestWrap(
            		id: Test(
            	 		id: 1 -> 2)))

if we set

val diff = Diff[TestWrapWrap].ignore(_.id)

then it ignores the optional id and it returns that they are identical

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

No branches or pull requests

1 participant