Coalesce icon indicating copy to clipboard operation
Coalesce copied to clipboard

[API] Remove default ordering by properties called "Name"

Open ascott18 opened this issue 6 years ago • 4 comments

Situation: I have a collection of objects that I want to return from an API in a specific order. These objects have a Name property on them. Coalesce takes over the ordering of this collection when mapping to the DTO, re-ordering them by Name and discarding my original ordering.

This behavior is pretty unintuitive, and would likely be hard for someone who isn't extensively experienced with Coalesce to figure out why its happening. While the auto-sorting by Name can often be useful, there is no way to suppress this behavior other than placing ordering attributes on another property, which I can't do in the situation described - there are no properties on the data that I'm ordering by - I simply want to maintain the original order of the items as they were placed in the collection.

On the flip side, if someone DOES want to order by Name, its very easy to add this behavior manually.

The default ordering fallback to primary key is also worth considering for removal, but only when mapping child collections - the default ordering by primary key of the root data being returned from the /list endpoint should remain.

@GrantErickson - thoughts?

ascott18 avatar May 23 '18 20:05 ascott18

Seems reasonable. Was the original ordering behavior there to make select lists automatically ordered?

adamskt avatar May 24 '18 16:05 adamskt

Another option would be to have slightly different default ordering behavior for top-level list results from a /list endpoint vs the ordering of child collections in the DTO mapping. Keep /list endpoints having the default ordering of their root data fall back to Name/primary key, but don't use the Name fallback default for child collections.

I do believe that is the intention by the default ordering by Name, yes.

ascott18 avatar May 24 '18 16:05 ascott18

The key here is to keep the admin pages sorted in a good default way.

GrantErickson avatar May 25 '18 05:05 GrantErickson

Doing nothing here for 3.0 because we haven't ran into this problem in a while. When someone runs into it again, we can re-evaluate and see if we can come up with a solution that makes sense. I don't know that removing the default ordering is the right solution here - I think the solution lies closer to a way that you could suppress the default ordering.

ascott18 avatar Jul 29 '20 22:07 ascott18