go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.09k stars 5.49k forks source link

Milestones not sorted by name in dropdown #31674

Open stuzer05 opened 3 months ago

stuzer05 commented 3 months ago

Description

No response

Gitea Version

1.23.0+dev-332-gba9589a92d

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

image

Git Version

No response

Operating System

No response

How are you running Gitea?

docker

Database

PostgreSQL

yp05327 commented 3 months ago

By default, it is sorted by name. But for the order in SQL, if there are numbers in it, they will be handled as characters.

stuzer05 commented 3 months ago

By default, it is sorted by name. But for the order in SQL, if there are numbers in it, they will be handled as characters.

There're workarounds to achieve natural order, such as

SELECT * FROM milestone WHERE repo_id = 40 ORDER BY LENGTH(name), name asc

image

yp05327 commented 3 months ago

Yes, LENGTH can fix this, but I'm not sure whether this function can be used in all DB. I have asked @lunny . And what about other names. e.g. project name, issue's title, organization/user name... So I think we need a general solution, but not only for milestones.

stuzer05 commented 3 months ago

In most cases alphabetical sorting would be best because that's the way we look. It's best to set it by default and use another sorting for specific cases

stuzer05 commented 3 months ago
RDBMS Supported? Notes
MySQL/MariaDB Yes
PostgreSQL Yes
Oracle Yes
SQL Server Yes Uses LEN(field) instead of LENGTH(field)
SQLite Yes
lunny commented 3 months ago

I know we can do that with SQL but I don't think the new order method can satisfy every situation. For example, assume the milestone names are A1111, B22, and C3. What's the right order do you think?

stuzer05 commented 3 months ago

A1111

Exactly as you typed: A1111, B22, C3. In this case it's grouped by "prefix". But here can be another meanings, I know