Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mockups for unique foreign keys #7

Open
sirex opened this Issue May 10, 2011 · 2 comments

Comments

Projects
None yet
3 participants

sirex commented May 10, 2011

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?

Owner

sorl commented May 13, 2011

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment