you would need to use the "on load" events to detect this and replace
the value with None using set_committed_value()
from sqlalchemy.orm import set_committed_value
from sqlalchemy import event
@event.listens_for(MyClass, "load")
@event.listens_for(MyClass, "refresh")
def _replace_currency(obj,
On Thu, May 11, 2017 at 6:18 PM, wrote:
> Hello,
>
> I have a Money composite column, comprised of an `amount` (Decimal) and a
> `currency` (String). Sometimes the amount needs to be NULL, but then I get
> an instance of Money(None, 'GBP'). Is there any way to force the composite
> to return None
Hello,
I have a Money composite column, comprised of an `amount` (Decimal) and a
`currency` (String). Sometimes the amount needs to be NULL, but then I get
an instance of Money(None, 'GBP'). Is there any way to force the composite
to return None in this case?
Thanks,
Alex
--
SQLAlchemy -
Th