Open sgithens opened 8 years ago
I'm looking at creating a few unit tests for this, and I see the avocado/tests/models.py
where I would put a 1:1 model and field, and I'm trying to determine which sub tests model would be the appropriate one to put some harvest queries to look at the number returned and if the empty 1:1 relationships are being excluded. It looks the best place might be tests/cases/models/tests.py
?
Any thoughts on the best location for tests that are verifying the number of harvest rows returned based on the employee models and fixtures?
Hi Steve, why don't you put it in that spot, and if Byron has a better idea at review time, he'll let you know. At this point, he and you are the best judges of the right location ;-).
@sgithens A one-to-one field as far as Django is concerned is:
similar to a ForeignKey with
unique=True
, but the “reverse” side of the relation will directly return a single object.
If you do have null
entries, then I am not sure what the behavior would actually be. My guess is that when Avocado attempts to format the data, a DoesNotExist
exception is thrown which may screw with the output.
Do you mind changing the field to a ForeignKey
to see if you see results in the client? This does not require any changes to the database schema.
I've had an issue with one of our datasets including django models with OneToOneFields. If a OneToOne field in a root result is null/empty in the database, then that item is excluded from the results. I would expect that this result would still be included, but that the columns/fields with an empty OneToOne relationship would just be empty in the returned Harvest results.
Currently, I am fixing this in our dataset by occasionally running a job that goes through the root model items, and if any of it's OneToOne fields are null, populating them with a related instance whose fields are all empty.