-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Feature Request
@BrapiCoordinatorSelby I think BrAPI lists serve the most use cases if they are ordered lists. Currently, there is nothing in the spec that requires ordering to be preserved. The BrAPI-Java-TestServer generally returns list items in the same order they were created in, but this is only due to the default order in which PostgreSQL returns rows when an ORDER BY clause is omitted and is not guaranteed by any means.
Possible Implementations
Adopt UUID v7
Version 7 UUIDs are time-sortable, the first 48 bits are a timestamp with millisecond precision. For entities created by the same system in the same millisecond, implementations usually use an increasing counter to ensure monotonicity within each millisecond as well.
Pros
- This doesn't require adding new fields.
Cons
- It's a little too clever, people generally won't look at a UUID and understand it's v7 and time-sortable. The purpose of an integer field called "position" for example is far more obvious.
- It's probably better to store and represent list order explicity.
- Poor options for existing data migration: either preserve primary keys of existing data and forgo time-sortability or migrate to UUID v7 and change primary keys of existing entities.
Add Field(s) to List Items
Adding a created timestamp and/or an integer list position field to list items could work in at least two ways. (1) The new field could be added to the API spec and explicitly passed back and forth when creating and reading lists (an integer position would make sense in this case) or (2) it could be a means of transparently preserving the original order of the list (a timestamp would be suitable in this case).
Pros
- Explicit, obvious function.
- Forces a data migration, but will not change primary keys.
Cons
- Requires change to API spec or at least data model.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status