Skip to content

Commit

Permalink
Merge pull request #236 from deeky666/DBAL-81
Browse files Browse the repository at this point in the history
[DBAL-81] Add auto-commit DBAL configuration option
  • Loading branch information
guilhermeblanco committed Feb 28, 2014
2 parents 941a69c + 0b56da0 commit df57980
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private function getDbalConnectionsNode()
->children()
->scalarNode('driver')->defaultValue('pdo_mysql')->end()
->scalarNode('platform_service')->end()
->booleanNode('auto_commit')->end()
->scalarNode('schema_filter')->end()
->booleanNode('logging')->defaultValue($this->debug)->end()
->booleanNode('profiling')->defaultValue($this->debug)->end()
Expand Down
6 changes: 6 additions & 0 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ protected function loadDbalConnection($name, array $connection, ContainerBuilder
}
unset($connection['profiling']);

if (isset($connection['auto_commit'])) {
$configuration->addMethodCall('setAutoCommit', array($connection['auto_commit']));
}

unset($connection['auto_commit']);

if (isset($connection['schema_filter']) && $connection['schema_filter']) {
$configuration->addMethodCall('setFilterSchemaAssetsExpression', array($connection['schema_filter']));
}
Expand Down
1 change: 1 addition & 0 deletions Resources/config/schema/doctrine-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<xsd:attribute name="platform-service" type="xsd:string" />
<xsd:attribute name="shard-choser" type="xsd:string" />
<xsd:attribute name="shard-choser-service" type="xsd:string" />
<xsd:attribute name="auto-commit" type="xsd:string" />
<xsd:attribute name="schema-filter" type="xsd:string" />
<xsd:attribute name="logging" type="xsd:string" default="false" />
<xsd:attribute name="profiling" type="xsd:string" default="false" />
Expand Down
4 changes: 4 additions & 0 deletions Resources/doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Configuration Reference
charset: UTF8
logging: %kernel.debug%
platform_service: MyOwnDatabasePlatformService
auto_commit: false
schema_filter: ^sf2_
mapping_types:
enum: string
Expand Down Expand Up @@ -98,6 +99,7 @@ Configuration Reference
charset="UTF8"
logging="%kernel.debug%"
platform-service="MyOwnDatabasePlatformService"
auto-commit="false"
schema-filter="^sf2_"
>
<doctrine:option key="foo">bar</doctrine:option>
Expand Down Expand Up @@ -272,6 +274,7 @@ can configure. The following block shows all possible configuration keys:
charset: UTF8
logging: %kernel.debug%
platform_service: MyOwnDatabasePlatformService
auto_commit: false
schema_filter: ^sf2_
mapping_types:
enum: string
Expand Down Expand Up @@ -300,6 +303,7 @@ can configure. The following block shows all possible configuration keys:
charset="UTF8"
logging="%kernel.debug%"
platform-service="MyOwnDatabasePlatformService"
auto-commit="false"
schema-filter="^sf2_"
>
<doctrine:option key="foo">bar</doctrine:option>
Expand Down
14 changes: 14 additions & 0 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,20 @@ public function testAttachEntityListeners()
)));
}

public function testDbalAutoCommit()
{
$container = $this->getContainer();
$loader = new DoctrineExtension();
$container->registerExtension($loader);

$this->loadFromFile($container, 'dbal_auto_commit');

$this->compileContainer($container);

$definition = $container->getDefinition('doctrine.dbal.default_connection.configuration');
$this->assertDICDefinitionMethodCallOnce($definition, 'setAutoCommit', array(false));
}

public function testDbalSchemaFilter()
{
$container = $this->getContainer();
Expand Down
12 changes: 12 additions & 0 deletions Tests/DependencyInjection/Fixtures/config/xml/dbal_auto_commit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal auto-commit="false" />
</config>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
doctrine:
dbal:
auto_commit: false

0 comments on commit df57980

Please sign in to comment.