add explicit handling for empty 1:many lists

This commit is contained in:
Michael Genson 2023-11-25 16:59:23 +00:00
parent fcd4854cb8
commit ff115284d9

View File

@ -20,5 +20,11 @@ class BaseMixins:
`self.update` method which directly passing arguments to the `__init__` `self.update` method which directly passing arguments to the `__init__`
""" """
def update(self, *args, **kwarg): def update(self, *args, **kwargs):
self.__init__(*args, **kwarg) self.__init__(*args, **kwargs)
# sqlalchemy doesn't like this method to remove all instances of a 1:many relationship,
# so we explicitly check for that here
for k, v in kwargs.items():
if hasattr(self, k) and v == []:
setattr(self, k, v)