public function testSelectShardNoDistriubtionValue() { $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer'))); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false)); $this->setExpectedException('Doctrine\\DBAL\\Sharding\\ShardingException', 'You have to specify a string or integer as shard distribution value.'); $sm = new SQLAzureShardManager($conn); $sm->selectShard(null); }
/** * {@inheritdoc} */ public function getDropAllSchema() { $this->shardManager->selectGlobal(); $globalSql = $this->synchronizer->getDropAllSchema(); if ($globalSql) { $sql[] = "-- Work on Root Federation\nUSE FEDERATION ROOT WITH RESET;"; $sql = array_merge($sql, $globalSql); } $shards = $this->shardManager->getShards(); foreach ($shards as $shard) { $this->shardManager->selectShard($shard['rangeLow']); $federationSql = $this->synchronizer->getDropAllSchema(); if ($federationSql) { $sql[] = "-- Work on Federation ID " . $shard['id'] . "\n" . "USE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " = " . $shard['rangeLow'] . ") WITH RESET, FILTERING = OFF;"; $sql = array_merge($sql, $federationSql); } } $sql[] = "USE FEDERATION ROOT WITH RESET;"; $sql[] = "DROP FEDERATION " . $this->shardManager->getFederationName(); return $sql; }
private function getCreateFederationStatement() { $federationType = Type::getType($this->shardManager->getDistributionType()); $federationTypeSql = $federationType->getSqlDeclaration(array(), $this->conn->getDatabasePlatform()); return "--Create Federation\n" . "CREATE FEDERATION " . $this->shardManager->getFederationName() . " (" . $this->shardManager->getDistributionKey() . " " . $federationTypeSql . " RANGE)"; }