Now, default behavior when creating mockups for foreign key fields is to reuse an existing object for that field. But if foreign keys are unique this behavior always ends up with error:
CreateInstanceError: Cannot solve constraints for "%s", tried 1000 times. Please check value generators or model constraints. At least the following fields are involved: myfield
To solve this I need to explicitly specify, that new object for that field should be created:
instance = mockups.create_one(Account, generate_fk=['myfield'])
Maybe it would be better to automatically create new object for unique fields? Or at least check if an existing object is not already assigned, if it is, then create new one?
Yes, that sounds reasonable i think.
It seems this is still an issue. Did you guys get around to solving this?
I notice that the OneToOneFieldGenerator is still just a "synonym" class to ForeignKeyFieldGenerator.
Don't you think it should contain some logic to follow the outcomes of the discussion in this thread?