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

Ignore structure inside Option field #443

Description

@gregorath

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions