Perhaps I have been up too many hours, but my syntax foo is fizzling. Given the following class, I want to compute the string length of "position" instead of storing it as another attribute which can get out of sync. eg.
class Position(Base):
__tablename__ = 'position'
id = Column(INTEGER, primary_key=True)
timestamp = Column(TIMESTAMP, nullable=False)
position = Column(TEXT, unique=True, nullable=False)
So to get all positions of string length 2, the following is not working:
from sqlalchemy.sql.expression import func
# ...
for position, in session.query(Position.position).filter(func.length(Position.position == 2):
print(position)
Any insight offered would certainly be appreciated.
Thanks!