drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Drush sql:query ON_ERROR_STOP is not implemented correctly (postgres) #6050

Open ryansabir opened 4 months ago

ryansabir commented 4 months ago

Describe the bug src/Sql/SqlPgsql.php line 47 is: return 'psql -q ON_ERROR_STOP=1 ';

This is the wrong syntax. The ON_ERROR_STOP is being ignored, you can see this if you remove the '-q' option.

To Reproduce Execute any drush sql command, e.g.: drush -v --debug sql-query "SELECT 1"

Now look at the SQL generated with the label 'Executing': Executing: psql -q ON_ERROR_STOP=1 --dbname=etc...

Expected behavior The sql generated should be: psql -q --set ON_ERROR_STOP=1

Actual behavior This causes an error on Windows when running any drush sql command. On MacOS (and presumably Linux) the variable is ignored.

Workaround Changing line 47 of src/Sql/SqlPgsql.php: return 'psql -q ON_ERROR_STOP=1 '; to return 'psql -q --set ON_ERROR_STOP=1 ';

Fixes it temporarily.

System Configuration

Q A
Drush version? 12.5.1.0
Drupal version? 10.2.4
PHP version 8.1.28
OS? Mac/Windows

Additional information This code was added as a fix for #5650. Tagging @weitzman .

flow6979 commented 3 months ago

Hey @ryansabir i would like to work on this issue, you can assign it to me. Thank you!!