Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a lpad function in a sql search string breaks completely the ability of database to use index .
Also when a sort is done on ref it is done using natural_search so sort should already use a natural search order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I understand that sorting with lpad is not efficient but I canot think to a better way of sorting this new field.
Currently, the natural search order may work when looking for something (meaning using the search parameter), but the sort order is wrongly displayed since it displays:
1 - adh.rowid_1
10 - adh.rowid_10
100 - adh.rowid_100
2 - adh.rowid_2
20 - adh.rowid_20
3 - adh.rowid_3
4 - adh.rowid_4
See discussion here :
https://www.dolibarr.fr/forum/t/tri-par-ref-anormal-dans-liste-adherents/41390
I can only see three ways to sort the list properly:
I'vd chose the first one cause it is not thé sort ordre by default, so the lpad fonction may not be call to often, but, for real it should be the second one witch is the best... but the ref field was created with the aim of no longer being equal to rowid so...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If order give
1 - adh.rowid_1
10 - adh.rowid_10
100 - adh.rowid_100
2 - adh.rowid_2
20 - adh.rowid_20
3 - adh.rowid_3
4 - adh.rowid_4
It means result is an alphabetical search. We want a sort on string for ref, not a sort on numeric. Don't forget that the ref is a string and will be later generated by a numbering rule like other modules.
It is temporarily a numeric for the transition, but value will soon be MEMyymm-99999
There is no real solution for natural sorting using sql, but this need should disappear when ref numbering will be implemented.