Is it possible to use the distinct function with out using the "session" class in sqlalchemy? Why or why not? The answer I found here:https://stackoverflow.com/a/35718413/10210394 seems like it should work but it doesn't work for me. See example below:
class Example(db.Model):
title = db.Column(db.String(140))
extra = db.Column(db.String(140))
e1 = Example(title='foo', extra='bar')
e2 = Example(title='hoo', extra='bar')
db.session.add_all([e1, e2])
db.session.commit()
test = []
for value in Example.query.distinct(Example.extra):
test.append(value.extra)
print(len(test))
...2
The result should be 1 not 2. Looking at the docs for distinct(), I feel like this should work. What am I missing?