Open ulinja opened 1 month ago
Yes, it is a string. the model field's type is JSONField
. but it seems the value type is string.
I think it can be json as the field type is JSONField
. not sure how we can change it without introducing a breaking change.
Probably by introducing a config flag like STORE_JSON_CHANGES
or something like that with the default value of False
. then by enabling this flag the changes will be stored in json and we can remove the config in the next major release.
BTW, this is an initial idea and needs some more investigation. Unfortunately, I don't have time to investigate.
@aqeelat @aleh-rymasheuski do you have any idea here?
When logging changes to model instances, the
changes
column casts all python data types into strings, rather than their JSON equivalents:None
->"None"
and notnull
True
->"True"
and nottrue
1
->"1"
and not1
and so on.
To illustrate this, consider the following model:
And with the following changes:
The values in the
changes
object stored in the database just get turned into strings, such that all type information is lost. Here is what thechanges
column looks like in the database:Instead, I would expect the following:
and the following JSON in the DB:
Am I doing something wrong or is this behavior intended?