Code

fix SQL generation for empty WHERE clause.
authorstefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 4 Nov 2010 22:31:39 +0000 (22:31 +0000)
committerstefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 4 Nov 2010 22:31:39 +0000 (22:31 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4571 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/backends/rdbms_common.py

index 2637f8868d04fe9d389ffdff70e5e002a2b89ca3..ae13ff27eded74408d6e0a254e927ca0c2eb5357 100644 (file)
@@ -2230,6 +2230,11 @@ class Class(hyperdb.Class):
             elif k == 'id':
                 if p.sort_type < 2:
                     if isinstance(v, type([])):
+                        # If there are no permitted values, then the
+                        # where clause will always be false, and we
+                        # can optimize the query away.
+                        if not v:
+                            return []
                         s = ','.join([a for x in v])
                         where.append('_%s.%s in (%s)'%(pln, k, s))
                         args = args + v