I'm a bit confused about filtering in SQLAlchemy.
I currently am trying to filter out entries greater than 10 weeks, so I have
current_time = datetime.datetime.utcnow()
potential = session.query(Subject).filter(Subject.time < current_time - datetime.timedelta(weeks=10))
However, the potential.count() always returns 0.
My theory is that I am not using the filter statement correctly because when I try to use a column that is not of type Column(DateTime()) but instead
Column(String(250))
like
potential = session.query(Subject).filter(Subject.string_field < current_time - datetime.timedelta(weeks=10))
SQLAlchemy will still not complain.
Also, when I do a manual check with
curr_time - session.query(Subject).first().time > datetime.timedelta(weeks=10)
I get True which implies that the count should not be 0.
Am I missing something obvious? Any help would be appreciated.

所有评论(0)