MSS
MSS copied to clipboard
'active': 'True' or a 'active': True (bool) needs a review
On an old database setup I have seen an error on unarchive of operations. This could also been introduced by https://github.com/Open-MSS/MSS/commit/02999a0356daa3f998a359b0e2120ac011b2f9a7#diff-a79f98f21772ef2875786e134f047c59410460de657ceda7b4829521ec2a87b8
sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: 'True'
[SQL: UPDATE operations SET active=? WHERE operations.id = ?]
[parameters: [{'active': 'True', 'operations_id': 9}]]
INFO: disconnected
This needs a test
Hi @ReimarBauer Can we explicitly check if the string is "True" (case-sensitive or case-insensitive) and then convert it to a boolean, instead of directly converting the value to a boolean? Jst like this
if isinstance(active, bool): self.active = active else: self.active = str(active).strip().lower() == 'true'