Esempio n. 1
0
 public function testFullfilledWithPartial()
 {
     $without = new Index('without', array('col1', 'col2'), true, false, array(), array());
     $partial = new Index('partial', array('col1', 'col2'), true, false, array(), array('where' => 'col1 IS NULL'));
     $another = new Index('another', array('col1', 'col2'), true, false, array(), array('where' => 'col1 IS NULL'));
     $this->assertFalse($partial->isFullfilledBy($without));
     $this->assertFalse($without->isFullfilledBy($partial));
     $this->assertTrue($partial->isFullfilledBy($partial));
     $this->assertTrue($partial->isFullfilledBy($another));
     $this->assertTrue($another->isFullfilledBy($partial));
 }
Esempio n. 2
0
 /**
  * Add index to table
  * 
  * @param Index $indexCandidate
  * @return Table
  */
 protected function _addIndex(Index $indexCandidate)
 {
     // check for duplicates
     foreach ($this->_indexes as $existingIndex) {
         if ($indexCandidate->isFullfilledBy($existingIndex)) {
             return $this;
         }
     }
     $indexName = $indexCandidate->getName();
     $indexName = strtolower($indexName);
     if (isset($this->_indexes[$indexName]) || $this->_primaryKeyName != false && $indexCandidate->isPrimary()) {
         throw SchemaException::indexAlreadyExists($indexName, $this->_name);
     }
     // remove overruled indexes
     foreach ($this->_indexes as $idxKey => $existingIndex) {
         if ($indexCandidate->overrules($existingIndex)) {
             unset($this->_indexes[$idxKey]);
         }
     }
     if ($indexCandidate->isPrimary()) {
         $this->_primaryKeyName = $indexName;
     }
     $this->_indexes[$indexName] = $indexCandidate;
     return $this;
 }
Esempio n. 3
0
 /**
  * Finds the difference between the indexes $index1 and $index2.
  *
  * Compares $index1 with $index2 and returns $index2 if there are any
  * differences or false in case there are no differences.
  *
  * @param \Doctrine\DBAL\Schema\Index $index1
  * @param \Doctrine\DBAL\Schema\Index $index2
  *
  * @return boolean
  */
 public function diffIndex(Index $index1, Index $index2)
 {
     if ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)) {
         return false;
     }
     return true;
 }