Comparing apple and oranges in AL and Business Central

Ғылым және технология

Yes, I got stumped by a single character string getting parsed as char, read more here: www.hougaard.com/?p=2936
Find more information at my blog www.hougaard.com or follow me on / ehougaard
Source code can be found here: github.com/hougaard/KZread-V...

Пікірлер: 6

  • @chriswatson2407
    @chriswatson24073 жыл бұрын

    You are incomparable!

  • @ibrahiemrasoelbaks5124
    @ibrahiemrasoelbaks51243 жыл бұрын

    Thanks Erik! Really interesting and very usefull in my daily work!

  • @bjarkihall2876
    @bjarkihall28763 жыл бұрын

    Thanks for the video! One thing that comes to mind is that JsonObject doesn't guarantee the order of keys, I believe. So J1.ReadFrom('{"Test":123, "Test2":456}') will not necessarily equal J2.ReadFrom('{"Test2":456,"Test":123}') when you format them, while they are in fact deeply equal key-value pairs. I've not tried the Format comparison (whether the objects were made via ReadFrom, Add or Clone methods) but I think you'd need to loop through J1.Keys + J1.Values (either shallow comparison or deep/recursive comparison) to know if two JsonObjects are equal (where the order of keys doesn't matter).

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    You're right, good chatch!

  • @phduck
    @phduck3 жыл бұрын

    The system id trick is a bit dangerous since it is really more reference equality, wheres FORMAT(x) == FORMAT(y) is value equality. It should also be noted that the records x and y might have different system ids in the database, but the record could be the same in-memory. The system id can be altered in-memory (not modified to DB) making them have the same. One could also fetch the same record as x and y, alter some other fields, suddenly FORMAT(x) != FORMAT(y) while x.SystemId == y.SystemId.

  • @Hougaard

    @Hougaard

    3 жыл бұрын

    Agreed, it's an imperfect solution, if only the platform had a Record.Compare() function :)

Келесі