MCPcopy
hub / github.com/django/django / test_exact_booleanfield

Method test_exact_booleanfield

tests/lookup/tests.py:1595–1606  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1593
1594 @skipUnless(connection.vendor == "mysql", "MySQL-specific workaround.")
1595 def test_exact_booleanfield(self):
1596 # MySQL ignores indexes with boolean fields unless they're compared
1597 # directly to a boolean value.
1598 product = Product.objects.create(name="Paper", qty_target=5000)
1599 Stock.objects.create(product=product, short=False, qty_available=5100)
1600 stock_1 = Stock.objects.create(product=product, short=True, qty_available=180)
1601 qs = Stock.objects.filter(short=True)
1602 self.assertSequenceEqual(qs, [stock_1])
1603 self.assertIn(
1604 "%s = True" % connection.ops.quote_name("short"),
1605 str(qs.query),
1606 )
1607
1608 @skipUnless(connection.vendor == "mysql", "MySQL-specific workaround.")
1609 def test_exact_booleanfield_annotation(self):

Callers

nothing calls this directly

Calls 3

createMethod · 0.45
filterMethod · 0.45
quote_nameMethod · 0.45

Tested by

no test coverage detected