Skip to content

Commit

Permalink
using exclude-table-data instead (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: psychok7 <nunok7@gmail.com>
  • Loading branch information
jonathan-s and psychok7 committed Nov 5, 2020
1 parent 2891834 commit 469c3fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions dbbackup/db/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _create_dump(self):
cmd = cmd + create_postgres_uri(self)

for table in self.exclude:
cmd += ' --exclude-table={}'.format(table)
cmd += ' --exclude-table-data={}'.format(table)
if self.drop:
cmd += ' --clean'

Expand Down Expand Up @@ -113,7 +113,7 @@ def _create_dump(self):

cmd += ' --format=custom'
for table in self.exclude:
cmd += ' --exclude-table={}'.format(table)
cmd += ' --exclude-table-data={}'.format(table)
cmd = '{} {} {}'.format(self.dump_prefix, cmd, self.dump_suffix)
stdout, stderr = self.run_command(cmd, env=self.dump_env)
return stdout
Expand Down
16 changes: 8 additions & 8 deletions dbbackup/tests/test_connectors/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ def test_create_dump_user(self, mock_dump_cmd):
def test_create_dump_exclude(self, mock_dump_cmd):
# Without
self.connector.create_dump()
self.assertNotIn(' --exclude-table=', mock_dump_cmd.call_args[0][0])
self.assertNotIn(' --exclude-table-data=', mock_dump_cmd.call_args[0][0])
# With
self.connector.exclude = ('foo',)
self.connector.create_dump()
self.assertIn(' --exclude-table=foo', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table-data=foo', mock_dump_cmd.call_args[0][0])
# With serveral
self.connector.exclude = ('foo', 'bar')
self.connector.create_dump()
self.assertIn(' --exclude-table=foo', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table=bar', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table-data=foo', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table-data=bar', mock_dump_cmd.call_args[0][0])

def test_create_dump_drop(self, mock_dump_cmd):
# Without
Expand Down Expand Up @@ -152,16 +152,16 @@ def test_create_dump(self, mock_dump_cmd):
def test_create_dump_exclude(self, mock_dump_cmd):
# Without
self.connector.create_dump()
self.assertNotIn(' --exclude-table=', mock_dump_cmd.call_args[0][0])
self.assertNotIn(' --exclude-table-data=', mock_dump_cmd.call_args[0][0])
# With
self.connector.exclude = ('foo',)
self.connector.create_dump()
self.assertIn(' --exclude-table=foo', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table-data=foo', mock_dump_cmd.call_args[0][0])
# With serveral
self.connector.exclude = ('foo', 'bar')
self.connector.create_dump()
self.assertIn(' --exclude-table=foo', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table=bar', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table-data=foo', mock_dump_cmd.call_args[0][0])
self.assertIn(' --exclude-table-data=bar', mock_dump_cmd.call_args[0][0])

def test_create_dump_drop(self, mock_dump_cmd):
# Without
Expand Down

0 comments on commit 469c3fc

Please sign in to comment.