← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1398470] [NEW] sql migration helpers incorrectly inspect for FKs

 

Public bug reported:

Our sql migration tests utilise the migration_helpers to execute such
things as adding and removing constraints. In the case of ForeignKeys,
the remove helper uses a method  like this:

def get_constraints_names(table, column_name):
    fkeys = [fk.name for fk in table.constraints
             if (column_name in fk.columns and
                  isinstance(fk, sqlalchemy.ForeignKeyConstraint)]
    return keys

The test for column name in fk_colums is unsafe as written, since there
are more than just ForeignKeyContraints in table.constraints (and they
don't all have a columns attribute). The check should first ensure the
item we are looking at IS a ForeignKey, and then check the column.

** Affects: keystone
     Importance: High
     Assignee: Henry Nash (henry-nash)
         Status: New

** Changed in: keystone
     Assignee: (unassigned) => Henry Nash (henry-nash)

** Changed in: keystone
   Importance: Undecided => High

** Changed in: keystone
    Milestone: None => kilo-1

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Keystone.
https://bugs.launchpad.net/bugs/1398470

Title:
  sql migration helpers incorrectly inspect for FKs

Status in OpenStack Identity (Keystone):
  New

Bug description:
  Our sql migration tests utilise the migration_helpers to execute such
  things as adding and removing constraints. In the case of ForeignKeys,
  the remove helper uses a method  like this:

  def get_constraints_names(table, column_name):
      fkeys = [fk.name for fk in table.constraints
               if (column_name in fk.columns and
                    isinstance(fk, sqlalchemy.ForeignKeyConstraint)]
      return keys

  The test for column name in fk_colums is unsafe as written, since
  there are more than just ForeignKeyContraints in table.constraints
  (and they don't all have a columns attribute). The check should first
  ensure the item we are looking at IS a ForeignKey, and then check the
  column.

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


Follow ups

References