コード例 #1
0
ファイル: UniqueTest.php プロジェクト: robin850/Propel2
 /**
  * @dataProvider provideTableSpecificAttributes
  *
  */
 public function testCreateDefaultUniqueIndexName($tableName, $maxColumnNameLength, $indexName)
 {
     $table = $this->getTableMock($tableName, array('common_name' => $tableName, 'unices' => array(new Unique(), new Unique()), 'database' => $this->getDatabaseMock('bookstore', array('platform' => $this->getPlatformMock(true, array('max_column_name_length' => $maxColumnNameLength))))));
     $index = new Unique();
     $index->setTable($table);
     $this->assertTrue($index->isUnique());
     $this->assertSame($indexName, $index->getName());
 }
コード例 #2
0
 /**
  * @dataProvider provideTableSpecificAttributes
  *
  */
 public function testCreateDefaultUniqueIndexName($tableName, $maxColumnNameLength, $indexName)
 {
     $database = $this->getDatabaseMock('bookstore');
     $database->expects($this->any())->method('getMaxColumnNameLength')->will($this->returnValue($maxColumnNameLength));
     $table = $this->getTableMock($tableName, ['common_name' => $tableName, 'unices' => [new Unique(), new Unique()], 'database' => $database]);
     $index = new Unique();
     $index->setTable($table);
     $this->assertTrue($index->isUnique());
     $this->assertSame($indexName, $index->getName());
 }
コード例 #3
0
 public function getUniqueDDL(Unique $unique)
 {
     return sprintf('UNIQUE INDEX %s (%s)', $this->quoteIdentifier($unique->getName()), $this->getIndexColumnListDDL($unique));
 }
コード例 #4
0
ファイル: OraclePlatform.php プロジェクト: smoqs/Propel2
 public function getUniqueDDL(Unique $unique)
 {
     return sprintf('CONSTRAINT %s UNIQUE (%s)', $this->quoteIdentifier($unique->getName()), $this->getColumnListDDL($unique->getColumnObjects()));
 }
コード例 #5
0
ファイル: Table.php プロジェクト: disider/Propel2
 /**
  * Adds a new Unique index to the list of unique indices and set the
  * parent table of the column to the current table.
  *
  * @param  Unique|array $unique
  * @return Unique
  */
 public function addUnique($unique)
 {
     if ($unique instanceof Unique) {
         $unique->setTable($this);
         $unique->getName();
         // we call this method so that the name is created now if it doesn't already exist.
         $this->unices[] = $unique;
         return $unique;
     }
     $unik = new Unique();
     $unik->loadMapping($unique);
     return $this->addUnique($unik);
 }
コード例 #6
0
ファイル: MssqlPlatform.php プロジェクト: naldz/cyberden
 /**
  * Builds the DDL SQL for a Unique constraint object. MS SQL Server CONTRAINT specific
  *
  * @param  Unique $unique
  * @return string
  */
 public function getUniqueDDL(Unique $unique)
 {
     $pattern = 'CONSTRAINT %s UNIQUE NONCLUSTERED (%s) ON [PRIMARY]';
     return sprintf($pattern, $this->quoteIdentifier($unique->getName()), $this->getColumnListDDL($unique->getColumnObjects()));
 }