fix issue 2027: bug in query serialization

discussion https://groups.google.com/d/topic/web2py/Gviq0NJIBsQ/discussion
issue https://code.google.com/p/web2py/issues/detail?id=2027