ewsterrenburg / python-otrs

Pythonic interface to OTRS SOAP API
GNU General Public License v3.0
47 stars 27 forks source link

In otrs/objects.py, assumptions made by "autocast" are error-prone (for values with a leading zero) #48

Open vincentborghi opened 3 years ago

vincentborghi commented 3 years ago

In my use case, I have a dynamic field "SR Number" which stores some external ticket number. The fact is that those ticket numbers are made of digits only and may begin with "0" (zero), like e.g. "01234567". When I search for tickets whose dynamic field "SR Number" is e.g. "01234567", this fails, because autocast changes the string value "01234567" to the "1234567" int, while I need it just stays as it is (the string "01234567").

I was obliged to modify the autocast function (in otrs/objects.py) by adding the 2 following lines just before the "try" statement: if s.startswith("0"):
return s

ewsterrenburg commented 2 years ago

Agreed that the current version is "too greedy", yet couldn't come to a simple fix yet that's doing the right thing in both Python 2 & Python 3 (your workaround doesn't work when the ticket numbers involved are actually integers).

Will think about it and look at this as well when scrapping out Python 2 compatibility.