MCPcopy
hub / github.com/django/django / test_partial_index

Method test_partial_index

tests/indexes/tests.py:384–414  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 9

create_sqlMethod · 0.95
IndexClass · 0.90
QClass · 0.90
schema_editorMethod · 0.80
cursorMethod · 0.80
quote_nameMethod · 0.45
add_indexMethod · 0.45
get_constraintsMethod · 0.45
remove_indexMethod · 0.45

Tested by

no test coverage detected