diff options
| author | Haolun Chai <hauluntsia@gmail.com> | 2022-08-14 05:12:56 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-08-15 06:28:35 +0200 |
| commit | f3f9d03edf17ccfa17263c7efa0b1350d1ac9278 (patch) | |
| tree | aaaebe64d84062d5d3e38650fd0ebc655ae2122f /tests/schema | |
| parent | e30d6678421b7573a1995f61521f14348c9b2a17 (diff) | |
Fixed #33901 -- Skipped varchar_pattern_ops/text_pattern_ops index creation when db_collation is set.
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 6fe35e7109..9e2385f5d8 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -1321,6 +1321,42 @@ class SchemaTests(TransactionTestCase): cs_collation, ) + @isolate_apps("schema") + @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific") + @skipUnlessDBFeature( + "supports_collation_on_charfield", + "supports_non_deterministic_collations", + ) + def test_unique_with_collation_charfield(self): + ci_collation = "case_insensitive" + + def drop_collation(): + with connection.cursor() as cursor: + cursor.execute(f"DROP COLLATION IF EXISTS {ci_collation}") + + with connection.cursor() as cursor: + cursor.execute( + f"CREATE COLLATION IF NOT EXISTS {ci_collation} (provider = icu, " + f"locale = 'und-u-ks-level2', deterministic = false)" + ) + self.addCleanup(drop_collation) + + class CiCharModel(Model): + field = CharField(max_length=16, db_collation=ci_collation, unique=True) + + class Meta: + app_label = "schema" + + # Create the table. + with connection.schema_editor() as editor: + editor.create_model(CiCharModel) + self.isolated_local_models = [CiCharModel] + self.assertEqual( + self.get_column_collation(CiCharModel._meta.db_table, "field"), + ci_collation, + ) + self.assertIn("field", self.get_uniques(CiCharModel._meta.db_table)) + def test_alter_textfield_to_null(self): """ #24307 - Should skip an alter statement on databases with |
