Opened 8 years ago
Closed 8 years ago
#26751 closed Cleanup/optimization (fixed)
Make dbshell exit with the shell's error code
Reported by: | Étienne BERSAC | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | dbshell |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
For scripting, commands should return a non zero exit-code on error. But dbshell
seems to ignore the exit code. Here is how to reproduce:
(venv) $ echo 'auieaui;' | django-admin dbshell ERROR: syntax error at or near "auieaui" LINE 1: auieaui; ^ (venv) $ echo $? 0
I suggested a fix in https://github.com/django/django/pull/6768 . @charettes asked me to open a ticket for discussion. Here your are :)
Regards,
Étienne
Change History (5)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|---|
Has patch: | set |
Patch needs improvement: | set |
Summary: | dbshell error handling → Make dbshell exit with the shell's error code |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 8 years ago
@timgraham, thanks for triaging :)
I applied the fix to other backends. That's actually not a problem of backends but how runshell manage subprocess.
comment:3 by , 8 years ago
You're rigth, it's quite hard to test execvp because by definition, this function never returns.
comment:4 by , 8 years ago
Patch needs improvement: | unset |
---|
Is a similar fix applicable for the other database backends? Not sure if tests are feasible.