Commit 2b523bc4 authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-222] Add SQL Azure Platform - currently only with Federations support.

parent a56e01cf
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Schema\Table;
/**
* Platform to ensure compatibility of Doctrine with SQL Azure
*
* On top of SQL Server 2008 the following functionality is added:
*
* - Create tables with the FEDERATED ON syntax.
*/
class SQLAzurePlatform extends SQLServer2008Platform
{
public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
{
$sql = parent::getCreateTableSQL($table, $createFlags);
if ($table->hasOption('azure.federatedOnDistributionName')) {
$distributionName = $table->getOption('azure.federatedOnDistributionName');
$columnName = $table->getOption('azure.federatedOnColumnName');
$stmt = ' FEDERATED ON (' . $distributionName . ' = ' . $columnName . ')';
$sql[0] = $sql[0] . $stmt;
}
return $sql;
}
}
<?php
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\Tests\DbalTestCase;
/**
* @group DBAL-222
*/
class SQLAzurePlatformTest extends DbalTestCase
{
private $platform;
public function setUp()
{
$this->platform = new \Doctrine\DBAL\Platforms\SQLAzurePlatform();
}
public function testCreateFederatedOnTable()
{
$table = new \Doctrine\DBAL\Schema\Table("tbl");
$table->addColumn("id", "integer");
$table->addOption('azure.federatedOnDistributionName', 'TblId');
$table->addOption('azure.federatedOnColumnName', 'id');
$this->assertEquals(array('CREATE TABLE tbl (id INT NOT NULL) FEDERATED ON (TblId = id)'), $this->platform->getCreateTableSQL($table));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment