/**
  * {@inheritdoc}
  */
 protected function addRow(array $row)
 {
     //Need to manage the primary flag if we are going to be updating/inserting data.
     if (!empty($this->def['primary_flag_column']) && $row[$this->def['primary_flag_column']]) {
         $rhsKey = $this->def['join_key_rhs'];
         $lhsKey = $this->def['join_key_lhs'];
         $db = DBManagerFactory::getInstance();
         // The primary flag is true, that means we need to block
         // out the old primary flag
         $query = "UPDATE {$this->getRelationshipTable()} SET " . "{$this->def['primary_flag_column']} = 0 WHERE ";
         if ($this->def['primary_flag_side'] == 'rhs') {
             $query .= "{$rhsKey} = '" . $db->quote($row[$rhsKey]) . "'";
         } else {
             $query .= "{$lhsKey} = '" . $db->quote($row[$lhsKey]) . "'";
         }
         $db->query($query);
     }
     return parent::addRow($row);
 }