Skip to content

Commit f1fd6d6

Browse files
tmp fix collation to insensitive
Signed-off-by: Anton Melser <[email protected]>
1 parent 18d7a6f commit f1fd6d6

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
@@ -38,6 +38,9 @@ def create_hash_digest(data_bytes: bytes, num_bytes=20) -> str:
3838

3939

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

0 commit comments

Comments
 (0)