-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4733 from mondrake/patch-1
Fix auto_increment implementation for Oracle
- Loading branch information
Showing
3 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Tests\Functional; | ||
|
||
use Doctrine\DBAL\Platforms\SQLServer2012Platform; | ||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
|
||
class AutoIncrementColumnTest extends FunctionalTestCase | ||
{ | ||
/** @var bool */ | ||
private $shouldDisableIdentityInsert = false; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$table = new Table('auto_increment_table'); | ||
$table->addColumn('id', 'integer', ['autoincrement' => true]); | ||
$table->setPrimaryKey(['id']); | ||
|
||
$this->connection->createSchemaManager() | ||
->dropAndCreateTable($table); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
if ($this->shouldDisableIdentityInsert) { | ||
$this->connection->executeStatement('SET IDENTITY_INSERT auto_increment_table OFF'); | ||
} | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
public function testInsertIdentityValue(): void | ||
{ | ||
if ($this->connection->getDatabasePlatform() instanceof SQLServer2012Platform) { | ||
$this->connection->executeStatement('SET IDENTITY_INSERT auto_increment_table ON'); | ||
$this->shouldDisableIdentityInsert = true; | ||
} | ||
|
||
$this->connection->insert('auto_increment_table', ['id' => 2]); | ||
self::assertEquals(2, $this->connection->fetchOne('SELECT id FROM auto_increment_table')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters