Re: orderBy isinstance str check
Oleg Broytman <[email protected]> Sat, 25 Oct 2014 21:44:12 +0200
| Newsgroups | gmane.comp.python.sqlobject |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Oct 25, 2014 at 12:42:32PM -0600, Andrew Trusty <[email protected]> wrote: > On Sat, Oct 25, 2014 at 12:09 PM, Oleg Broytman <[email protected]> wrote: > > > > I recently discovered that some of my code was passing unicode strings to > > > orderBy and that this worked as long as the strings didn't start with > > "-". > > > When they did start with "-", the _mungeOrderBy check (line 69 in > > > sresults.py) didn't detect the "-" because the strings were of type > > unicode > > > and not type str and _mungeOrderBy checks for str and not basestring. > > > > > If you replace 'str' with > > 'basestring' in 'if isinstance(orderBy, str)' does it work for you? > > Yes, that works for me. Ok, I'll fix that. Thank you for spotting! I'm going to release 1.5.3 and 1.6.1. What version are you using? > I wasn't sure if that was the only change that was > needed or if some of the other isinstance checks might need to be changed > to check basestring as well. There are many occurrences of 'isinstance(x, str)' all over SQLObject sources. You can try to fix them and test. I'll accept a patch or a pull request and test it if you provide one. Oleg. -- Oleg Broytman http://phdru.name/ [email protected] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------