What is the __metadata__ field in new versions of Ash?

I just updated my Ash to the latest version 2.13.2. After that, I noticed that a lot of my unit tests stopped working basically because I was comparing resources. From what I can see, when I create the resource, the __metadata__ field will be a empty map %{}, but when I fetch the same resource with a read action, it will contain a key called selected in that map with the list of fields that were selected. Was this a new addition? Is there some way to disable that in tests so I can compare resources maps instead of having to process then before doing my asserts?
4 Replies
ZachDaniel
ZachDaniel2y ago
How old was your previous version?
Blibs
BlibsOP2y ago
i think I was in 2.10.something
ZachDaniel
ZachDaniel2y ago
In general, comparing instances of resources using == is not a good idea, unfortunately. There is a utility in Ash.Test called strip_metadata that you can use to clean lists/pages/instances of resources of their metadata for comparison
assert strip_metadata(some_records) == strip_metadata(some_other_records)
assert strip_metadata(some_records) == strip_metadata(some_other_records)
Blibs
BlibsOP2y ago
Ah, cool! Thanks, I will try that out

Did you find this page helpful?