Hi there,
We have a class similar to this definition:
class Article(SQLObject):
publishedDate = DateTimeCol()
runningTime = IntCol() # This is the number of days the article
# runs after being published
To now query for Articles that are still within their running time, you
can do something like this (assuming Postgresql):
Article.select("(age(article.published_date)) < (article.running_time *
'1 day'::interval)")
Not very pretty, and in our real app, we cannot do this anyways for
unrelated reasons.
Is there a way to express this in Python instead?
Or how else could one do it? (I wondered if you can add a computed
attribute on the class, and somehow have SQLBuilder understand that...
but I imagine that's not possible.)
In the above, age is actually a postgresql function, so that part you
can write using the "q magic" in python. But the multiplication (and
the typecast) on the other end is problematic to write in Python.
-i