sqlors returning "1=2"

7 views
Skip to first unread message

xOneca

unread,
Nov 9, 2012, 7:34:55 PM11/9/12
to we...@googlegroups.com
Hello!

Why does sqlors function (https://github.com/webpy/webpy/blob/master/web/db.py#L351) return "1=2" at the end of the OR'ed list?

From the source's example:

    >>> sqlors('foo = ', [1,2,3])
    <sql: '(foo = 1 OR foo = 2 OR foo = 3 OR 1=2)'>

And in the code:

    return SQLQuery(['('] +
        sum([[left, sqlparam(x), ' OR '] for x in lst], []) +
        ['1=2)']
    )

Why not instead make the list without the last OR?

    ['('] + sum([[left, sqlparam(x), ' OR '] for x in lst], [])[:-1] + [')']

Regards.
Reply all
Reply to author
Forward
0 new messages