Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sql function for natural order by #31095

Open
hregis opened this issue Sep 23, 2024 · 4 comments
Open

Add sql function for natural order by #31095

hregis opened this issue Sep 23, 2024 · 4 comments
Assignees
Labels
Feature request This is a feature request

Comments

@hregis
Copy link
Contributor

hregis commented Sep 23, 2024

Feature Request

Use a sql function for natural order by

Use case

No response

Suggested implementation

I propose to add these sql functions to Dolibarr in order to have lists ordered in a natural order

natsort copie.txt

TRUC001
TRUC002
TRUC010

instead

TRUC001
TRUC010
TRUC002

Suggested steps

you can test this sql functions with :

$sql.= " ORDER BY udf_NaturalSortFormat(".$sortfield.", 10, '.') ".$sortorder.";

remains to make these functions compatible with Postgresql...
which is not currently the case in the creation syntax

@hregis hregis added the Feature request This is a feature request label Sep 23, 2024
@hregis
Copy link
Contributor Author

hregis commented Sep 23, 2024

this is can be include in "order" function of DoliDB class with constant and parameter

@hansemschnokeloch
Copy link
Contributor

Natural_sort_key is implemented in MariaDB since version 10.7 (but not in mysql)
https://mariadb.com/kb/en/natural_sort_key/

@hregis
Copy link
Contributor Author

hregis commented Dec 31, 2024

@hansemschnokeloch @eldy maybe add a function in the meantime to use either the MariaDB function or the function I propose?

https://modern-sql.com/caniuse/natural_sort_key

@eldy
Copy link
Member

eldy commented Dec 31, 2024

@hansemschnokeloch @eldy maybe add a function in the meantime to use either the MariaDB function or the function I propose?

https://modern-sql.com/caniuse/natural_sort_key

Pb is that support will not be available on all installation. So i suggest to first introduce this as a hidden constant into the order method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request This is a feature request
Projects
None yet
Development

No branches or pull requests

3 participants