Open stuzer05 opened 1 month 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.
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
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.
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
RDBMS | Supported? | Notes |
---|---|---|
MySQL/MariaDB | Yes | |
PostgreSQL | Yes | |
Oracle | Yes | |
SQL Server | Yes | Uses LEN(field) instead of LENGTH(field) |
SQLite | Yes |
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?
A1111
Exactly as you typed: A1111
, B22
, C3
. In this case it's grouped by "prefix". But here can be another meanings, I know
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
Git Version
No response
Operating System
No response
How are you running Gitea?
docker
Database
PostgreSQL