You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage/library_factories/sqlalchemy_factory.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ SQLAlchemyFactory allows to override some configuration attributes so that a des
19
19
Relationship
20
20
++++++++++++
21
21
22
-
By default, ``__set_relationships__`` is set to ``False``. If it is ``True``, all fields with the SQLAlchemy `relationship() <relationship()_>`_ will be included in the result created by ``build`` method.
22
+
By default, ``__set_relationships__`` is set to ``True``. If it is ``True``, all fields with the SQLAlchemy `relationship() <relationship()_>`_ will be included in the result created by ``build`` method.
@@ -34,7 +34,7 @@ By default, ``__set_relationships__`` is set to ``False``. If it is ``True``, al
34
34
Association Proxy
35
35
+++++++++++++++++
36
36
37
-
By default, ``__set_association_proxy__`` is set to ``False``. If it is ``True``, all SQLAlchemy fields mapped to ORM `Association Proxy <Association Proxy_>`_ class will be included in the result created by ``build`` method.
37
+
By default, ``__set_association_proxy__`` is set to ``True``. If it is ``True``, all SQLAlchemy fields mapped to ORM `Association Proxy <Association Proxy_>`_ class will be included in the result created by ``build`` method.
frompolyfactory.fieldsimportIgnore, PostGenerated, Require, Use
60
58
frompolyfactory.utils.helpersimport (
61
59
flatten_annotation,
62
60
get_collection_type,
@@ -116,7 +114,7 @@ class BaseFactory(ABC, Generic[T]):
116
114
The model for the factory.
117
115
This attribute is required for non-base factories and an exception will be raised if it's not set. Can be automatically inferred from the factory generic argument.
118
116
"""
119
-
__check_model__: bool=False
117
+
__check_model__: bool=True
120
118
"""
121
119
Flag dictating whether to check if fields defined on the factory exists on the model or not.
122
120
If 'True', checks will be done against Use, PostGenerated, Ignore, Require constructs fields only.
@@ -202,7 +200,7 @@ class BaseFactory(ABC, Generic[T]):
msg=f"required configuration attribute '__model__' is not set on {cls.__name__}"
227
-
raiseConfigurationException(
228
-
msg,
229
-
)
230
-
cls.__model__=model
231
-
ifnotcls.is_supported_type(model):
232
-
forfactoryinBaseFactory._base_factories:
233
-
iffactory.is_supported_type(model):
234
-
msg=f"{cls.__name__} does not support {model.__name__}, but this type is supported by the {factory.__name__} base factory class. To resolve this error, subclass the factory from {factory.__name__} instead of {cls.__name__}"
235
-
raiseConfigurationException(
236
-
msg,
237
-
)
238
-
msg=f"Model type {model.__name__} is not supported. To support it, register an appropriate base factory and subclass it for your factory."
msg=f"required configuration attribute '__model__' is not set on {cls.__name__}"
238
+
raiseConfigurationException(
239
+
msg,
240
+
)
241
+
cls.__model__=model
242
+
ifnotcls.is_supported_type(model):
243
+
forfactoryinBaseFactory._base_factories:
244
+
iffactory.is_supported_type(model):
245
+
msg=f"{cls.__name__} does not support {model.__name__}, but this type is supported by the {factory.__name__} base factory class. To resolve this error, subclass the factory from {factory.__name__} instead of {cls.__name__}"
246
+
raiseConfigurationException(
247
+
msg,
248
+
)
249
+
msg=f"Model type {model.__name__} is not supported. To support it, register an appropriate base factory and subclass it for your factory."
0 commit comments