Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drush sql-query should exit with failure status if query fails #34

Closed
rfay opened this issue Aug 26, 2013 · 7 comments
Closed

drush sql-query should exit with failure status if query fails #34

rfay opened this issue Aug 26, 2013 · 7 comments

Comments

@rfay
Copy link

rfay commented Aug 26, 2013

Currently, drush sql-query exits with a 0 even if there was an error in the query:

[rfay@dev-web11 current]$ drush sqlq 'select * from nothing;'
ERROR 1146 (42S02) at line 1: Table 'xxx_dev.nothing' doesn't exist
[rfay@dev-web11 current]$ echo $?
0

I think it would be useful to all of us if it returned an error status in a case like this.

Thanks!

greg-1-anderson added a commit that referenced this issue Aug 26, 2013
@greg-1-anderson
Copy link
Member

Above are the commits to master and 8.x-6.x. Did not backport to 7.x-5.x as an overly-cautious nod to backwards compatibility. I think this could go in 5.x if anyone felt strongly that it shoudl.

@rfay
Copy link
Author

rfay commented Aug 26, 2013

I would very much like it to go into 5.x, if that would be possible.

@rfay
Copy link
Author

rfay commented Aug 26, 2013

But wow, what amazing responsiveness! Thanks!

greg-1-anderson added a commit that referenced this issue Aug 26, 2013
@greg-1-anderson
Copy link
Member

Backported to 7.x-5.x. Seems like a pretty slim chance that anyone would have a script broken because they expected the script to keep running after a failed sql-query command. If anyone has any problems with this, please re-open, or just back out the change.

@weitzman
Copy link
Member

Actually, that _drush_sql_query is an API function used elsewhere (I think). We should probably throw an error in the command callback, drush_sql_query().

@weitzman weitzman reopened this Aug 28, 2013
@greg-1-anderson
Copy link
Member

You're right, I put that in the wrong place. I fixed it in master, 6.x and 5.x, but forgot to mention this issue in the commit comment.

The commit on master was b8522b3

mradcliffe pushed a commit to mradcliffe/drush that referenced this issue Sep 12, 2013
mradcliffe pushed a commit to mradcliffe/drush that referenced this issue Sep 12, 2013
@plach79
Copy link
Contributor

plach79 commented Sep 1, 2017

I'm still experiencing this on 8.x, apparently drush_sql_cli() does not set an explicit error when the process fails and returning FALSE is not enough to set a non-zero exit status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants