(self)
| 382 | available_apps = ["indexes"] |
| 383 | |
| 384 | def test_partial_index(self): |
| 385 | with connection.schema_editor() as editor: |
| 386 | index = Index( |
| 387 | name="recent_article_idx", |
| 388 | fields=["pub_date"], |
| 389 | condition=Q( |
| 390 | pub_date__gt=datetime.datetime( |
| 391 | year=2015, |
| 392 | month=1, |
| 393 | day=1, |
| 394 | # PostgreSQL would otherwise complain about the lookup |
| 395 | # being converted to a mutable function (by removing |
| 396 | # the timezone in the cast) which is forbidden. |
| 397 | tzinfo=timezone.get_current_timezone(), |
| 398 | ), |
| 399 | ), |
| 400 | ) |
| 401 | self.assertIn( |
| 402 | "WHERE %s" % editor.quote_name("pub_date"), |
| 403 | str(index.create_sql(Article, schema_editor=editor)), |
| 404 | ) |
| 405 | editor.add_index(index=index, model=Article) |
| 406 | with connection.cursor() as cursor: |
| 407 | self.assertIn( |
| 408 | index.name, |
| 409 | connection.introspection.get_constraints( |
| 410 | cursor=cursor, |
| 411 | table_name=Article._meta.db_table, |
| 412 | ), |
| 413 | ) |
| 414 | editor.remove_index(index=index, model=Article) |
| 415 | |
| 416 | def test_integer_restriction_partial(self): |
| 417 | with connection.schema_editor() as editor: |
nothing calls this directly
no test coverage detected