Skip to content

Commit cb4a48b

Browse files
tmp fix collation to insensitive
Signed-off-by: Anton Melser <[email protected]>
1 parent 8bc745c commit cb4a48b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

openedx_learning/apps/authoring/publishing/migrations/0009_create_case_insensitive_collation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55

66
class Migration(migrations.Migration):
7-
dependencies = [
8-
("oel_publishing", "0008_alter_draftchangelogrecord_options_and_more"),
7+
run_before = [
8+
("oel_publishing", "0001_initial"),
99
]
10-
1110
operations = [
1211
# Create a custom case-insensitive collation for PostgreSQL.
1312
# This collation is used by case_insensitive_char_field() to provide
@@ -29,7 +28,7 @@ class Migration(migrations.Migration):
2928
CreateCollation(
3029
"case_insensitive",
3130
provider="icu",
32-
locale="en-US",
31+
locale="und-u-ks-level2",
3332
deterministic=False,
3433
),
3534
]

openedx_learning/lib/fields.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import hashlib
1515
import uuid
1616

17-
from django.db import models
17+
from django.db import connection, models
1818

1919
from .collations import MultiCollationMixin
2020
from .validators import validate_utc_datetime
@@ -37,6 +37,9 @@ def create_hash_digest(data_bytes: bytes) -> str:
3737

3838

3939
def default_case_insensitive_collations_args(**kwargs):
40+
# Remove db_index from kwargs if using PostgreSQL to avoid collation issues
41+
if connection.vendor == "postgresql":
42+
kwargs = {k: v for k, v in kwargs.items() if k != "db_index"}
4043
return {
4144
"null": False,
4245
"db_collations": {

0 commit comments

Comments
 (0)