Closed jjmerchante closed 2 years ago
I have a question about the JSONField. I have included some tests that now fail, but I don't understand why.
As far as I understand there is a function to serialize the JSONFields and it is registered with @convert_django_field.register(JSONField)
. It works for Operation.args
but it doesn't work for Dataset.filters
by default. I don't know what I'm missing.
I have a question about the JSONField. I have included some tests that now fail, but I don't understand why.
As far as I understand there is a function to serialize the JSONFields and it is registered with
@convert_django_field.register(JSONField)
. It works forOperation.args
but it doesn't work forDataset.filters
by default. I don't know what I'm missing.
What's the error you are getting?
Debugging, the error is returned here:
executed = client.execute(BT_DATASETS_QUERY,
context_value=self.context_value)
datasets = executed['data']['datasets']['entities']
{'errors': [{'message': 'the JSON object must be str, bytes or bytearray, not dict'}], 'data': {'datasets': {'entities': [None]}}}
and debugging a bit more it raises here: https://github.com/chaoss/grimoirelab-bestiary/blob/unicorn/bestiary/core/schema.py#L99
The value is a dictionary and it expects an string. I see that in Operations the JSONField is stored as a string instead of a dictionary: https://github.com/chaoss/grimoirelab-bestiary/blob/3e26e65583ab65ccddf795d52b290922bae5985a/bestiary/core/log.py#L139, so I guess I should do the same for the Dataset (store filters as string in the JSONField)
This Pull request includes the following changes:
null=True
attribute in Ecosystem and fix some tests that weren't using a default Ecosystem.Every change has its related tests.