-
Notifications
You must be signed in to change notification settings - Fork 399
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
Add unique_constraints, a more versatile replacement for django_get_or_create and sqlalchemy_get_or_create #794
base: master
Are you sure you want to change the base?
Commits on Oct 11, 2020
-
Expose memleak in SQLAlchemyModelFactory.
The code responsible for `get_or_create` places a copy of the passed-in params on the factory class itself; which is kept after the instance has been created. Those fields are part of the BuildStep context, and should be fetched from there instead. The issue also occurs in DjangoModelFactory. See #781 for details.
Configuration menu - View commit details
-
Copy full SHA for a55ec38 - Browse repository at this point
Copy the full SHA a55ec38View commit details -
Add an optional normalization to class Meta fields
This could be used to ensure that an entry is actually a list.
Configuration menu - View commit details
-
Copy full SHA for 11fe368 - Browse repository at this point
Copy the full SHA 11fe368View commit details -
Provide support for migrating class Meta fields
Through `def _get_renamed_options()`, a specific `FactoryOptions` subclass may now indicate that one of its fields should now use another name, and optionally another syntax. The warning message displays the new format to use when adjusting the option.
Configuration menu - View commit details
-
Copy full SHA for 5d0b77f - Browse repository at this point
Copy the full SHA 5d0b77fView commit details -
Add
unique_constraints
and associated _lookup()Declare unique constraints on field values through this new `class Meta` option. When building a new instance, the parameters will first be resolved for each unique constraint, and a dedicated lookup performed; an instance will only be created if each lookup failed. Declarations are resolved lazily: a non-constraint SubFactory will only be called if each previous constraint lookup failed.
Configuration menu - View commit details
-
Copy full SHA for f292b70 - Browse repository at this point
Copy the full SHA f292b70View commit details -
Replace *_get_or_create with unique_constraints.
This change deprecates django_get_or_create and sqlalchemy_get_or_create; upgrade helpers are provided throught the option renaming helpers. Closes #241 The new `unique_constraints` feature is more powerful, but supports the exact same cases; a specific case has been added to opt out of lookups for `Factory.build()` and `Factory.stub()`. Examples are provided for Django and SQLAlchemy unique constraint declarations. Closes #69 With the implementation of `unique_constraints` - and its lazy declaration resolution algorithm, non-constrained declarations will only be resolved once lookups have failed; this avoids creating orphan objects. Closes #781 The call-time parameters are now explicitly included in the lookup algorithm; they no longer need to be kept attached to the factory class, which leaked instances.
Configuration menu - View commit details
-
Copy full SHA for 7bfe247 - Browse repository at this point
Copy the full SHA 7bfe247View commit details -
Configuration menu - View commit details
-
Copy full SHA for 772a067 - Browse repository at this point
Copy the full SHA 772a067View commit details -
Rename a StepBuilder instance to step_builder
The variable is a StepBuilder, not a BuildStep...
Configuration menu - View commit details
-
Copy full SHA for 2a87857 - Browse repository at this point
Copy the full SHA 2a87857View commit details