-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-db no longer supported. #170
Comments
Yes, that's an issue; however, I don't think the behavior you describe has ever worked in the last 3 years :/ The workaround you've described is the best solution right now. This issue originates from a feature that says "if you're settings unique fields through |
In the past, we were able to override the It does seem odd to me that when using the |
Related to issues #78, #92, #103, #111, #153, #170 The default value of all sequences is now 0; the automagic ``_setup_next_sequence`` behavior of Django/SQLAlchemy has been removed. This feature's only goal was to allow the following scenario: 1. Run a Python script that uses MyFactory.create() a couple of times (with a unique field based on the sequence counter) 2. Run the same Python script a second time Without the magical ``_setup_next_sequence``, the Sequence counter would be set to 0 at the beginning of each script run, so both runs would generate objects with the same values for the unique field ; thus conflicting and crashing. The above behavior having only a very limited use and bringing various issues (hitting the database on ``build()``, problems with non-integer or composite primary key columns, ...), it has been removed. It could still be emulated through custom ``_setup_next_sequence`` methods, or by calling ``MyFactory.reset_sequence()``.
This issue has been fixed in 13d310f, and will be part of the 2.5.0 release. |
In
DjangoModelFactory
, the factory will eventually make a call to_setup_next_sequence
regardless of whether we arebuild
ing orcreate
ing. This means the strategy of building an instance, then settings it's destination viasave(using='other_db')
is no longer valid.When using
factory.BUILD_STRATEGY
, it should not be hitting the database at all.I can mitigate this issue by overriding the
_setup_next_sequence()
method.The text was updated successfully, but these errors were encountered: