Skip to content

cli/db: show the actual error that occurred during sql script execution, if any

David Douard requested to merge douardda/swh-core:db-init-show-exc into master

When executing a swh db init command, the executed sql files for the package may fail, but the 'swh db' tool would eat the error reported by sqlsh. Make these errors shown as output of the process if such an error occurred.

e.g.:

  $ swh db init test:fail

  Error during database setup
  Command '['psql', '--quiet', '--no-psqlrc', '-v', 'ON_ERROR_STOP=1', '-d', 'postgresql://postgres@127.0.0.1:24370/tests', '-f', '/venv/swh-environment/swh-core/swh/core/db/tests/data/test/fail/sql/40-funcs.sql']' returned non-zero exit status 3.
  Process output:
  psql:/venv/swh-environment/swh-core/swh/core/db/tests/data/test/fail/sql/40-funcs.sql:6: ERROR:  function public.digest(text, unknown) does not exist
  LINE 5:     select encode(public.digest($1, 'sha1'), 'hex')
                          ^
  HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

  Aborted!
Edited by David Douard

Merge request reports

Loading