kopia lustrzana https://github.com/wagtail/wagtail
Explicitly set the wagtailcore_page.path column to use the 'C' collation.
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which sort numbers after letters. To avoid this, we explicitly set the collation for the 'path' column to the (non-locale-specific) 'C' collation. Ref: https://groups.google.com/d/msg/wagtail/q0leyuCnYWI/I9uDvVlyBAAJpull/2125/head
rodzic
973529f290
commit
a6d3d23e64
|
@ -6,6 +6,20 @@ from django.conf import settings
|
|||
import wagtail.wagtailsearch.index
|
||||
|
||||
|
||||
def set_page_path_collation(apps, schema_editor):
|
||||
"""
|
||||
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which
|
||||
sort numbers after letters. To avoid this, we explicitly set the collation for the
|
||||
'path' column to the (non-locale-specific) 'C' collation.
|
||||
|
||||
See: https://groups.google.com/d/msg/wagtail/q0leyuCnYWI/I9uDvVlyBAAJ
|
||||
"""
|
||||
if schema_editor.connection.vendor == 'postgresql':
|
||||
schema_editor.execute("""
|
||||
ALTER TABLE wagtailcore_page ALTER COLUMN path TYPE VARCHAR(255) COLLATE "C"
|
||||
""")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
|
@ -82,6 +96,9 @@ class Migration(migrations.Migration):
|
|||
},
|
||||
bases=(models.Model, wagtail.wagtailsearch.index.Indexed),
|
||||
),
|
||||
migrations.RunPython(
|
||||
set_page_path_collation, migrations.RunPython.noop
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='PageRevision',
|
||||
fields=[
|
||||
|
|
|
@ -116,6 +116,20 @@ def remove_initial_data(apps, schema_editor):
|
|||
# have been assigned such permissions and its harmless to leave them.
|
||||
|
||||
|
||||
def set_page_path_collation(apps, schema_editor):
|
||||
"""
|
||||
Treebeard's path comparison logic can fail on certain locales such as sk_SK, which
|
||||
sort numbers after letters. To avoid this, we explicitly set the collation for the
|
||||
'path' column to the (non-locale-specific) 'C' collation.
|
||||
|
||||
See: https://groups.google.com/d/msg/wagtail/q0leyuCnYWI/I9uDvVlyBAAJ
|
||||
"""
|
||||
if schema_editor.connection.vendor == 'postgresql':
|
||||
schema_editor.execute("""
|
||||
ALTER TABLE wagtailcore_page ALTER COLUMN path TYPE VARCHAR(255) COLLATE "C"
|
||||
""")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
replaces = [
|
||||
|
@ -226,6 +240,9 @@ class Migration(migrations.Migration):
|
|||
},
|
||||
bases=(models.Model, wagtail.wagtailsearch.index.Indexed),
|
||||
),
|
||||
migrations.RunPython(
|
||||
set_page_path_collation, migrations.RunPython.noop
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GroupPagePermission',
|
||||
fields=[
|
||||
|
|
Ładowanie…
Reference in New Issue