Comments (4)
@guacs correct!
from polyfactory.
@ShtykovaAA yeah this is definitely possible. The default values are parsed and stored when parsing the model already so this shouldn't be a difficult addition.
Just to clarify, when setting __use_defaults__ = True
then the default value will be used for all the fields that have a default value or default factory. This is the expected behavior, correct?
from polyfactory.
@adhtruong am I right in thinking we don't have to worry about the defaults when it comes to the SQLAFactory
since that would be handled by sqlalchemy
itself?
from polyfactory.
@guacs SQLAlchemy has a couple forms on default
- https://docs.sqlalchemy.org/en/20/orm/mapping_api.html#sqlalchemy.orm.mapped_column.params.default an in memory default
- Or an insert default
In both cases, omitting the parameter itself should trigger using the default. Case 1 could be handled the same as above implementation but 2 is a bit more complex as may rely on a db (e.g. primary key with sequence).
from polyfactory.
Related Issues (20)
- Bug: settings `__set_as_default_factory_for_type__ ` to `True` on base factory fails
- Bug: Pydantic fields with constraints and multiple type hints cause `ParameterException` HOT 1
- Bug: Optional constrained types do not work HOT 8
- Bug: ModelFactory can not generate list of classes with a Pydantic field alias HOT 1
- bug: support column.type `impl` attribute HOT 1
- Bug: Setting `ge` and `multiple_of` but not `le` constraints causes invalid values to be generated HOT 2
- Docs: Add example to use `PydanticFactory` with SQLAlchemy persistence HOT 5
- Bug: Data generated incorrectly from nested Annotated HOT 4
- Bug: Try to use SQLAlchemyFactory for model with column_property HOT 4
- Bug: UUIDBase ID Value Changed from UUID to Bytes HOT 4
- Enhancement: Support for dictionaries with Pydantic models as value, e.g. dict[str, PydanticClass] HOT 1
- Bug: Invalid Coverage for Optional Fields with Annotated Constraint
- Bug: pyright incompatability HOT 1
- Any not supported in provider_map
- Doubt in usage of polyfactory HOT 1
- Bug: Optional lists in coverage produce nested lists HOT 1
- Bug: sqlalchemy factory `column_property` in `get_model_fields` not working HOT 3
- Docs: Document functions/classes/methods that have no docstrings and are missing from the built docs
- Enhancement(Infra): Replace `black` with `ruff format`
- Bug(CI): Updated lockfile changes type checking CI causing failures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polyfactory.