'Test type of boolean fields when retrieved via select_related() (MySQL,
#15040)'

def test_select_related(self):

    bmt = BooleanModel.objects.create(bfield=True)
    bmf = BooleanModel.objects.create(bfield=False)
    nbmt = NullBooleanModel.objects.create(nbfield=True)
    nbmf = NullBooleanModel.objects.create(nbfield=False)
    m1 = FksToBooleans.objects.create(bf=bmt, nbf=nbmt)
    m2 = FksToBooleans.objects.create(bf=bmf, nbf=nbmf)
    ma = FksToBooleans.objects.select_related(u'bf').get(pk=m1.id)
    self.assertIsInstance(ma.bf.bfield, bool)
    self.assertIsInstance(ma.nbf.nbfield, bool)
    self.assertEqual(ma.bf.bfield, True)
    self.assertEqual(ma.nbf.nbfield, True)
    mb = FksToBooleans.objects.select_related().get(pk=m1.id)
    mc = FksToBooleans.objects.select_related().get(pk=m2.id)
    self.assertIsInstance(mb.bf.bfield, bool)
    self.assertIsInstance(mb.nbf.nbfield, bool)
    self.assertIsInstance(mc.bf.bfield, bool)
    self.assertIsInstance(mc.nbf.nbfield, bool)
    self.assertEqual(mb.bf.bfield, True)
    self.assertEqual(mb.nbf.nbfield, True)
    self.assertEqual(mc.bf.bfield, False)
    self.assertEqual(mc.nbf.nbfield, False)
