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
Set a more complex dictionary for the data JSON field when generating objects with the factory:
# Include the code that provoked the bug, including as full a stack-trace as possibleobj=ModelFactory(
data={
"apples": [
{
"apple_id": 1,
"apple_color": "red",
}
]
}
)
The object is created, but the data field is persisted as:
{"apples": []}
Notes
SQLAlchemy==1.4.46
factory-boy==3.1.0
The text was updated successfully, but these errors were encountered:
Your SQLAlchemy code is incomplete; it is not enough to define a class with some attribute. SQLAlchemy uses declarative mapping. You also need to create a session instance and and not just provide the Session class to SQLAlchemyModelFactory.
Description
Not sure if this is a Factory Boy bug or SQLAlchemy bug.
When trying to persist more complex dictionaries within a JSON field/column of a SQLAlchemy model, the data is only partially persisted.
Model / Factory code
The issue
Set a more complex dictionary for the
data
JSON field when generating objects with the factory:The object is created, but the
data
field is persisted as:{"apples": []}
Notes
The text was updated successfully, but these errors were encountered: