refresh_from_db changes type of field?

Given the following model:

from django.db import models

class my_choice(models.TextChoices):
    YES = "Y", "Yes"
    NO = "N", "No"

class DemoClass(models.Model):

    the_choice = models.CharField(
        max_length=2, 
        choices=my_choice.choices, 
        default=my_choice.YES
    )

the function refresh_from_db() alters the type of the field the_choice:

>>> from refresh.models import DemoClass
>>> d = DemoClass.objects.create()
>>> type(d.the_choice)
<enum 'my_choice'>
>>> d.refresh_from_db()
>>> type(d.the_choice)
<class 'str'>

Is this behavior intentional?

I have duplicated your results. I believe the reason for the shown behavior is that the field is a CharField, not a my_choice field. In other words, the value of the field is a string, not the enum. The database has no concept of your enum class, so when it returns the field value, it is a simple string, and Django does not re-cast the value into an enum because the field is a CharField. The “choices” parameter in the field declaration only provide which values can be put into the string field, not including any identity they may have had as part of their enum. I hope this helps?

Thank you for your comments. They are in line with my thoughts. My question, however, is whether this behavior is intentional? I find it surprising that by refresh_from_db() a change of the data type takes place. Is this behavior documented anywhere?