Another try. Backing out psql error changes (#678).

This commit is contained in:
Dan Helfman 2023-04-21 10:34:50 -07:00
parent 7e64f415ba
commit 5962fd473e
6 changed files with 11 additions and 13 deletions

View file

@ -1,3 +1,4 @@
---
kind: pipeline
name: python-3-8-alpine-3-13
@ -5,7 +6,6 @@ services:
- name: postgresql
image: docker.io/postgres:13.1-alpine
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
- name: mysql

1
NEWS
View file

@ -7,7 +7,6 @@
commands with arguments.
* #678: Fix calls to psql in PostgreSQL hook to ignore "~/.psqlrc", whose settings can break
database dumping.
* #678: Fix calls to psql in PostgreSQL hook to abort on error during a database restore.
* #682: Fix "source_directories_must_exist" option to expand globs and tildes in source directories.
* #684: Rename "master" development branch to "main" to use more inclusive language. You'll need to
update your development checkouts accordingly.

View file

@ -229,11 +229,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run,
restore_command = (
tuple(psql_command if use_psql_command else pg_restore_command)
+ ('--no-password',)
+ (
('--no-psqlrc', '--set', 'ON_ERROR_STOP=on')
if use_psql_command
else ('--if-exists', '--exit-on-error', '--clean')
)
+ (('--no-psqlrc',) if use_psql_command else ('--if-exists', '--exit-on-error', '--clean'))
+ (('--dbname', database['name']) if not all_databases else ())
+ (('--host', database['hostname']) if 'hostname' in database else ())
+ (('--port', str(database['port'])) if 'port' in database else ())

View file

@ -3,7 +3,6 @@ services:
postgresql:
image: docker.io/postgres:13.1-alpine
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
mysql:

View file

@ -36,17 +36,17 @@ hooks:
postgresql_databases:
- name: test
hostname: postgresql
username: test
username: postgres
password: test
format: {postgresql_dump_format}
- name: all
hostname: postgresql
username: test
username: postgres
password: test
- name: all
format: custom
hostname: postgresql
username: test
username: postgres
password: test
mysql_databases:
- name: test

View file

@ -656,7 +656,11 @@ def test_restore_database_dump_runs_psql_for_all_database_dump():
flexmock(module).should_receive('make_dump_path')
flexmock(module.dump).should_receive('make_database_dump_filename')
flexmock(module).should_receive('execute_command_with_processes').with_args(
('psql', '--no-password', '--no-psqlrc', '--set', 'ON_ERROR_STOP=on'),
(
'psql',
'--no-password',
'--no-psqlrc',
),
processes=[extract_process],
output_log_level=logging.DEBUG,
input_file=extract_process.stdout,
@ -680,7 +684,7 @@ def test_restore_database_dump_runs_psql_for_plain_database_dump():
flexmock(module).should_receive('make_dump_path')
flexmock(module.dump).should_receive('make_database_dump_filename')
flexmock(module).should_receive('execute_command_with_processes').with_args(
('psql', '--no-password', '--no-psqlrc', '--set', 'ON_ERROR_STOP=on', '--dbname', 'foo'),
('psql', '--no-password', '--no-psqlrc', '--dbname', 'foo'),
processes=[extract_process],
output_log_level=logging.DEBUG,
input_file=extract_process.stdout,