Skip to content

Commit 859e73c

Browse files
authored
Merge pull request #62 from skollro/use-inserts
Use --inserts option for pgsql connections by default
2 parents 60313f8 + 804198b commit 859e73c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/DbDumperFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected static function forDriver($dbDriver): DbDumper
4646
}
4747

4848
if ($driver === 'pgsql') {
49-
return new PostgreSql();
49+
return (new PostgreSql())->useInserts();
5050
}
5151

5252
if ($driver === 'sqlite') {

tests/DbDumperFactoryTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function it_can_add_named_options_to_the_dump_command()
8686

8787
$this->app['config']->set('database.connections.mysql.dump', $dumpConfig);
8888

89-
$this->assertContains('--single-transaction', $this->getDumpCommand());
89+
$this->assertContains('--single-transaction', $this->getDumpCommand('mysql'));
9090
}
9191

9292
/** @test */
@@ -96,7 +96,7 @@ public function it_can_add_named_options_with_an_array_value_to_the_dump_command
9696

9797
$this->app['config']->set('database.connections.mysql.dump', $dumpConfig);
9898

99-
$this->assertContains(implode(' ', $dumpConfig['include_tables']), $this->getDumpCommand());
99+
$this->assertContains(implode(' ', $dumpConfig['include_tables']), $this->getDumpCommand('mysql'));
100100
}
101101

102102
/** @test */
@@ -106,14 +106,20 @@ public function it_can_add_arbritrary_options_to_the_dump_command()
106106

107107
$this->app['config']->set('database.connections.mysql.dump', $dumpConfig);
108108

109-
$this->assertContains($dumpConfig['add_extra_option'], $this->getDumpCommand());
109+
$this->assertContains($dumpConfig['add_extra_option'], $this->getDumpCommand('mysql'));
110110
}
111111

112-
protected function getDumpCommand(): string
112+
/** @test */
113+
public function it_adds_the_inserts_option_to_the_pgsql_dump_command()
114+
{
115+
$this->assertContains('--inserts', $this->getDumpCommand('pgsql'));
116+
}
117+
118+
protected function getDumpCommand(string $connectionName): string
113119
{
114120
$dumpFile = '';
115121
$credentialsFile = '';
116122

117-
return DbDumperFactory::createForConnection('mysql')->getDumpCommand($dumpFile, $credentialsFile);
123+
return DbDumperFactory::createForConnection($connectionName)->getDumpCommand($dumpFile, $credentialsFile);
118124
}
119125
}

0 commit comments

Comments
 (0)