- changed status to wontfix
Hybrid Attribut raises a TypeError when the getter calls `datetime.date.strftime` on an DATE-attribute
Issue #2705
resolved
Please see the attached example.py: if you uncomment line 21, there is no error.
tested on versions: - '0.7.4' - '0.8.0'
Comments (1)
-
repo owner - Log in to comment
well this one there's an issue with your class' behavioral contract. You're saying
Example(my_date=x)
, which means you're asking declarative to use the default constructor to establish this value, but it checks it by askinghasattr(Example, 'my_date')
.What happens if we do that?
it asserts False. Because, your hybrid is assuming that it's called only as an in-Python expression, not a SQL expression. The
Example._date
attribute doesn't have astrftime()
method, you'd need to implement this as an equivalent SQL expression, otherwise there's not much point in using@hybrid_property
, you would just use@property
instead.So here it'll work if you put something that's compatible with
Example.my_date
:I used
pdb.set_trace()
inside ofdef my_date()
to figure this out.