mirror of
https://github.com/rommapp/romm.git
synced 2026-04-18 12:09:38 +00:00
fix on mariadb
This commit is contained in:
@@ -798,14 +798,15 @@ class DBRomsHandler(DBBaseHandler):
|
||||
|
||||
# Ignore case when the order attribute is a number
|
||||
if isinstance(order_attr.type, (String, Text)):
|
||||
# Remove any leading articles
|
||||
# Remove any leading articles (text is already lowercased, so no "i" flag needed)
|
||||
order_attr = func.trim(
|
||||
func.lower(order_attr).regexp_replace(STRIP_ARTICLES_REGEX, "", "i")
|
||||
func.lower(order_attr).regexp_replace(STRIP_ARTICLES_REGEX, "")
|
||||
)
|
||||
|
||||
# Pad numbers with leading zeros to ensure natural sorting
|
||||
order_attr = order_attr.regexp_replace(
|
||||
r"(\d+)", r"00000000000\1", "g"
|
||||
).regexp_replace(r"0*(\d{12})", r"\1", "g")
|
||||
r"(\d+)", r"00000000000\1"
|
||||
).regexp_replace(r"0*(\d{12})", r"\1")
|
||||
|
||||
if order_dir.lower() == "desc":
|
||||
order_attr = order_attr.desc()
|
||||
@@ -876,18 +877,19 @@ class DBRomsHandler(DBBaseHandler):
|
||||
session: Session = None, # type: ignore
|
||||
) -> list[Row[tuple[str, int]]]:
|
||||
if isinstance(order_by_attr.type, (String, Text)):
|
||||
# Remove any leading articles
|
||||
# Remove any leading articles (text is already lowercased, so no "i" flag needed)
|
||||
order_by_attr = func.trim(
|
||||
func.lower(order_by_attr).regexp_replace(STRIP_ARTICLES_REGEX, "", "i")
|
||||
func.lower(order_by_attr).regexp_replace(STRIP_ARTICLES_REGEX, "")
|
||||
)
|
||||
else:
|
||||
order_by_attr = func.trim(
|
||||
func.lower(Rom.name).regexp_replace(STRIP_ARTICLES_REGEX, "", "i")
|
||||
func.lower(Rom.name).regexp_replace(STRIP_ARTICLES_REGEX, "")
|
||||
)
|
||||
|
||||
# Pad numbers with leading zeros to ensure natural sorting
|
||||
order_by_attr = order_by_attr.regexp_replace(
|
||||
r"(\d+)", r"00000000000\1", "g"
|
||||
).regexp_replace(r"0*(\d{12})", r"\1", "g")
|
||||
r"(\d+)", r"00000000000\1"
|
||||
).regexp_replace(r"0*(\d{12})", r"\1")
|
||||
|
||||
# Get the row number and first letter for each item
|
||||
subquery = (
|
||||
|
||||
Reference in New Issue
Block a user