You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
I have a question regarding the behaviour of the diff for case classes. Here is a short example:
importcom.softwaremill.diffx._caseclassFooBar(
foo: String,
bar: String
)
objectFooBar {
implicitvalfooBarDiff:Diff[FooBar] =Diff.derived
}
"compare" should "return IdenticalValue for the same instance" in {
valfooBarInstance=FooBar("a", "b")
valdiffResult= compare(fooBarInstance, fooBarInstance)
diffResult shouldBe IdenticalValue(fooBarInstance)
}
In a case like this, it was obvious that I'd receive IdenticalValue. Instead, the test fails with:
DiffResultObject(FooBar,ListMap(foo -> IdenticalValue(a), bar -> IdenticalValue(b))) was not equal to IdenticalValue(FooBar(a,b))
Is it intended behaviour? If it is, is there any alternative that will allow me to receive an IdenticalValue when the fields are identical and DiffResultObject when the fields are different? Of course, my example is simplified. My real scenario contains a larger hierarchy of nested objects, so manually creating a Diff will be quite hard.
I know that I can use isIdentical but I'd like to extract the whole identical entity from the diff. DiffResultObject contains only the name and a map of fields.
When I was using version 0.4.5 it worked as expected. My current diffx version is 0.8.0.
The text was updated successfully, but these errors were encountered:
Yes, the change was made deliberately to improve rendering of big structures when they are identical but contain some ignored fields inside.
Atm there is no way to retrieve the full original entity. This is a use-case that I didn't take into account.
Could you shed some light on what for do you actually need that identical instance? Maybe there is some bigger issue that we should aim to resolve instead.
My use case was to do a diff on an entity and then produce an event with the entity based on the result. For identical entities, it was just an IdentitcalEntityEvent with the entity itself. Now, when I get a DiffResultObject, I cannot extract this entity and produce the event easily.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I have a question regarding the behaviour of the diff for case classes. Here is a short example:
In a case like this, it was obvious that I'd receive
IdenticalValue
. Instead, the test fails with:Is it intended behaviour? If it is, is there any alternative that will allow me to receive an
IdenticalValue
when the fields are identical andDiffResultObject
when the fields are different? Of course, my example is simplified. My real scenario contains a larger hierarchy of nested objects, so manually creating aDiff
will be quite hard.I know that I can use
isIdentical
but I'd like to extract the whole identical entity from the diff.DiffResultObject
contains only the name and a map of fields.When I was using version 0.4.5 it worked as expected. My current diffx version is 0.8.0.
The text was updated successfully, but these errors were encountered: