← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1292285] Re: equal_any() DB API helper produces incorrect SQL query

 

** Changed in: nova
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1292285

Title:
  equal_any() DB API helper produces incorrect SQL query

Status in OpenStack Compute (Nova):
  Fix Released

Bug description:
  Given an attribute name and a list of values equal_any() is meant to
  produce a WHERE clause which returns rows for which the column
  (denoted by an attribute of an SQLAlchemy model) is equal to ANY of
  passed values that involves using of SQL OR operator. In fact, AND
  operator is used to combine equality expressions.

  E.g. for a model:

  class Instance(BaseModel):
      __tablename__ = 'instances'

     id = sa.Column('id', sa.Integer, primary_key=True)
     ...
     task_state = sa.Column('task_state', sa.String(30))

  using of equal_any():

    q = model_query(context, Instance).
    constraint = Constraint({'task_state': equal_any('error', 'deleting')})
    q = constraint.apply(Instance, q)

  will produce:

  SELECT * from instances
  WHERE task_state = 'error' AND task_state = 'deleting'

  instead of expected:

  SELECT * from instances
  WHERE task_state = 'error' OR task_state = 'deleting'

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1292285/+subscriptions


References