SQLObject.select appears to generates bogus SQL if an empty string is passed as the first arg

Bug #3096 reported by Brad Bollenbach
12
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Christian Reis

Bug Description

In the BugSet.searchAsUser update that I'm about to submit to pqm, there's some code like this:

        if where_clauses:
            return Bug.select(
                ' AND '.join(where_clauses), **other_params)
        else:
            return Bug.select(**other_params)

which works as expected (i.e. bug.txt passes.) But changing that to:

        return Bug.select("", **other_params)

causes exception output like:

...
    ProgrammingError: ERROR: syntax error at end of input at character 32

    SELECT COUNT(*) FROM Bug WHERE
...

when running the bug.txt test.

Instead, I would have expected my tests to fail (because I've changed the behaviour to have empty filter criteria), but not raise ProgrammingError exceptions.

Brad Bollenbach (bradb)
Changed in launchpad:
assignee: nobody → spiv
Brad Bollenbach (bradb)
description: updated
Revision history for this message
Christian Reis (kiko) wrote :

Yeah, it's an SQLObject bug. The trivial workaround is using "1=1", which I believe can be found in our codebase in places.

Revision history for this message
Dafydd Harries (daf) wrote :

Would it be worth it to forward this bug upstream?

Changed in launchpad:
status: New → Accepted
Christian Reis (kiko)
Changed in launchpad:
assignee: spiv → kiko
Revision history for this message
Christian Reis (kiko) wrote :

Finally. And a one-liner it was, too.

Changed in launchpad:
status: Confirmed → Fix Committed
Christian Reis (kiko)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.