Bug 824050 - [BUG] bad key_value entry will create an empty where clause
[BUG] bad key_value entry will create an empty where clause
Product: Beaker
Classification: Community
Component: scheduler (Show other bugs)
Unspecified Unspecified
unspecified Severity high (vote)
: 0.9.0
: ---
Assigned To: Dan Callaghan
Depends On:
  Show dependency treegraph
Reported: 2012-05-22 12:11 EDT by Bill Peck
Modified: 2012-06-26 02:40 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-06-26 02:40:29 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Bill Peck 2012-05-22 12:11:58 EDT
Description of problem:
Put an invalid key_value entry in hostrequires and it will produce an empty where clause which will cause the query to fail.

Version-Release number of selected component (if applicable):

How reproducible:
100% with the right recipe.

Steps to Reproduce:
1. put the following in <hostRequires> <key_value key="system_type" op="=" value="Machine"/>
Comment 1 Dan Callaghan 2012-05-23 03:19:06 EDT
Seems the only way to reproduce this is to filter on two non-existent keys joined by an <and/>:

                    <key_value key="NOTEXIST1" op="=" value="asdf"/>
                    <key_value key="NOTEXIST2" op="=" value="asdf"/>

It doesn't happen if one of the keys does exist, or if there is only one <key_value/> filter in the <and/>.
Comment 2 Dan Callaghan 2012-05-23 03:22:43 EDT
I guess this is why:

>>> print System.query.filter(and_(None)).filter(System.private == False)
FROM system 
WHERE system.private = %s
>>> print System.query.filter(and_(None, None)).filter(System.private == False)
FROM system 
WHERE  AND system.private = %s
Comment 3 Dan Callaghan 2012-05-23 03:37:01 EDT
On Gerrit: http://gerrit.beaker-project.org/1085
Comment 5 Dan Callaghan 2012-06-26 02:40:29 EDT
Beaker 0.9.0 has been released.

Note You need to log in before you can comment on or make changes to this bug.