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
I'm finding that my objects are left on a transient state, and that attributes have the wrong type. I've review the docs and other issues on the issue tracker, and I can't see what I am doing wrong.
The serialization of this response fails. If I set a breakpoint, I see that just before generating the response, after the object has been created, added to the session and commited, this is how the object looks like:
As you can see, the date is on string format, which is not correct as it should be a datetime.date, given that it's declared on the model as my_date = db.Column(db.Date, nullable=True). Also, id and created are not initialized either, as expected of a transient object.
The created object is added to the session and it is committed properly. Proof is that if I remove the db_session fixture, the code works and the record is created on the DB. Using postman I am also able to verify it. Any insight?
The text was updated successfully, but these errors were encountered:
I'm finding that my objects are left on a transient state, and that attributes have the wrong type. I've review the docs and other issues on the issue tracker, and I can't see what I am doing wrong.
I have a
pytest.ini
file with:And a
conftest.py
:If you are curious about
create_app
, it's a straightforward Flask app factory:I have this simple test which POSTs a string and a date, used to instantiate and commit a SQLAlchemy model:
The serialization of this response fails. If I set a breakpoint, I see that just before generating the response, after the object has been created, added to the session and commited, this is how the object looks like:
As you can see, the date is on string format, which is not correct as it should be a
datetime.date
, given that it's declared on the model asmy_date = db.Column(db.Date, nullable=True)
. Also,id
andcreated
are not initialized either, as expected of a transient object.The created object is added to the session and it is committed properly. Proof is that if I remove the
db_session
fixture, the code works and the record is created on the DB. Using postman I am also able to verify it. Any insight?The text was updated successfully, but these errors were encountered: