Skip to content

Commit

Permalink
fix: fix sorting tags on MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Oct 20, 2023
1 parent 868f3b8 commit ee6d554
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions openedx_tagging/core/tagging/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,11 @@ def _get_filtered_tags_deep(
# For a root tag, we want sort_key="RootValue" and for a depth=1 tag
# we want sort_key="RootValue\tValue". The following does that, since
# ConcatNull(...) returns NULL if any argument is NULL.
Coalesce(ConcatNull(F("parent__parent__parent__value"), Value("\t")), Value("")),
Coalesce(ConcatNull(F("parent__parent__value"), Value("\t")), Value("")),
Coalesce(ConcatNull(F("parent__value"), Value("\t")), Value("")),
ConcatNull(F("parent__parent__parent__value"), Value("\t")),
ConcatNull(F("parent__parent__value"), Value("\t")),
ConcatNull(F("parent__value"), Value("\t")),
F("value"),
Value("\t"), # We also need the '\t' separator character at the end, or MySQL will sort things wrong
output_field=models.CharField(),
))
# Add the parent value
Expand Down

0 comments on commit ee6d554

Please sign in to comment.