| | 19 | |
| | 20 | For anyone running into this problem you can register field instance lookups to work around the problem |
| | 21 | |
| | 22 | {{{#!python |
| | 23 | from django.db.models.lookups import Contains, IContains |
| | 24 | |
| | 25 | class Foo(models.Model): |
| | 26 | bar = models.TextField(db_collation="und-u-ks-level2") |
| | 27 | |
| | 28 | |
| | 29 | # See https://docs.djangoproject.com/en/5.1/howto/custom-lookups/#a-lookup-example |
| | 30 | class NonDetermisticContains(Contains): |
| | 31 | def as_postgresql(self, compiler, connection): |
| | 32 | lhs, lhs_params = self.process_lhs(compiler, connection) |
| | 33 | rhs, rhs_params = self.process_rhs(compiler, connection) |
| | 34 | params = lhs_params + rhs_params |
| | 35 | return f'{lhs} COLLATE "default"' LIKE {rhs}', params |
| | 36 | |
| | 37 | Foo._meta.get_field("bar").register_lookup(NonDetermisticContains) |
| | 38 | }}} |