Coder Social home page Coder Social logo

Comments (4)

chkalch avatar chkalch commented on June 4, 2024

I made more tests and it seems that ordering is always the same for same inputs, but differs for other strings, but ordering is not alphabetically.

I also found out that there is no difference in the output when inserting strings at a different position (other index in path), so either index in path is ignored completely or some sorting is applied afterwards.

from base-repo.

ThomasJejkal avatar ThomasJejkal commented on June 4, 2024

While this issue has impact in base-repo, it actually relates to kit-data-manager/service-base and src/main/java/edu/kit/datamanager/util/PatchUtil.java. However, also there only a third party library is used where it comes to the following line of code at the end: https://github.com/java-json-tools/json-patch/blob/55b27b96045baa4ef356b2b183304551f64a18e4/src/main/java/com/github/fge/jsonpatch/AddOperation.java#L130

As one can see, the index is properly evaluated and the new element should be added at the correct position, but there is a "but". Afterwards, the modified resource is written to the basebase and what you see as an "array" is actually represented as Set of strings, which has no index/primary key that can be utilized for sorting as it is the case for sets of complex objects. For strings, only uniqueness of entries, but no specific order is guaranteed from the database side. This indeed leads to unpredictable behaviour in terms of ordering, but I'm afraid it is working as intended. ;-)

from base-repo.

chkalch avatar chkalch commented on June 4, 2024

Indeed, it's also not possible to add the same value twice (never tried that before), which also points to a set rather than an array.

Of course I would prefer that the order is retained and arrays behave like arrays (there are no sets in JSON specification) and JSON-Patch works like it should according to specification, but this would probably be more work than just adding an additional order/index column to the database - but it would also make repo more versatile.

So at least it should be clearly communicated everywhere in the documentation where these "set-arrays" occur, I used this documentation to dive into this topic and would suggest that you add a prominent notice at the top of the page.

from base-repo.

ThomasJejkal avatar ThomasJejkal commented on June 4, 2024

Thanks for the pointer, I've added a note.

from base-repo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.