Bug 824050 - [BUG] bad key_value entry will create an empty where clause
Summary: [BUG] bad key_value entry will create an empty where clause
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: scheduler
Version: 0.9
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Dan Callaghan
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-22 16:11 UTC by Bill Peck
Modified: 2019-05-22 13:41 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-26 06:40:29 UTC
Embargoed:


Attachments (Terms of Use)

Description Bill Peck 2012-05-22 16:11:58 UTC
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):
0.8.2

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 07:19:06 UTC
Seems the only way to reproduce this is to filter on two non-existent keys joined by an <and/>:

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

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 07:22:43 UTC
I guess this is why:

>>> print System.query.filter(and_(None)).filter(System.private == False)
SELECT ... 
FROM system 
WHERE system.private = %s
>>> print System.query.filter(and_(None, None)).filter(System.private == False)
SELECT ... 
FROM system 
WHERE  AND system.private = %s

Comment 3 Dan Callaghan 2012-05-23 07:37:01 UTC
On Gerrit: http://gerrit.beaker-project.org/1085

Comment 5 Dan Callaghan 2012-06-26 06:40:29 UTC
Beaker 0.9.0 has been released.


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