Closed (fixed)
Project:
Drush
Version:
All-versions-3.x-dev
Component:
Core Commands
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Aug 2010 at 09:09 UTC
Updated:
26 Oct 2010 at 16:40 UTC
Jump to comment: Most recent file
Comments
Comment #1
moshe weitzman commentedI can't reproduce this. WHat params are you using?
I tried the new testing install profile and I get
Comment #2
joachim commentedI'm doing just 'drush si'.
Granted, 'drush' on my system is a bash alias for 'php ~/Sites/_sandbox/drush-HEAD/drush.php' but that shouldn't change anything surely.
Comment #3
joachim commentedThe problem is this line:
and the problem is the hyphen.
The same line with a database called 'hello' works fine.
Comment #4
joachim commentedThe people in #mysql suggested to wrap the db name in ' or ` -- neither of which work for me on the command line.
Ultimately, was told to use mysqladmin rather than mysql.
Comment #5
moshe weitzman commentedmysqladmin would add a new requirement. folks would have to specify the path to that command if not on $PATH. could someone try to write a patch where we save our queries to a file and then redirect that into mysql command. thats much more common in drush than the -e param. something like:
mysql < tmpfile.sqlSee _drush_sql_query() for an example.
Comment #6
joachim commentedNot sure that'll do it.
Really crappy patch to show what I was trying -- still get the same error message using a file.
Comment #7
joachim commentedBetter title.
Comment #8
joachim commentedAsked on StackOverflow and got this answer:
$ mysql -hlocalhost -uuser -ppass -e "CREATE DATABASE \`foo-bar\`"
I've tested this on the commandline and it works perfectly! :D
Simple patch (on 3.x) which fixes the problem attached.
Comment #9
greg.1.anderson commentedUndocumented backticks? Do regular single-quotes work?
Comment #10
joachim commentedNope.
Undocumented in that when I googled and looked on MySQL I couldn't find anything about escaping on the commandline.
Comment #11
jonhattanBacktick is the character to quote identifiers in mysql. It doesn't matter if your using -e in the command line or are inside mysql cli or using .sql files.
Not an undocumented thing though http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
This needs extra quotation because backticks have a meaning in bash (or *sh?):
$ mysql -hlocalhost -uuser -ppass -e "CREATE DATABASE \`foo-bar\`"
but this is fine for bash:
$ mysql -hlocalhost -uuser -ppass -e 'CREATE DATABASE `foo-bar`'
Comment #12
joachim commentedIn light of that, here's a reroll with a more appropriate comment.
Comment #13
jonhattanFinally did commit with that comment:
...to fit 80 chars length for doxygen.
Comment #14
joachim commentedGreat!
The patch should apply on 3.x too.
Comment #15
moshe weitzman commentedI'd rather not screw up someone's script by adding some escaping on 3.x
Comment #16
joachim commentedHow would escaping just the DB name screw up a script?
Comment #17
moshe weitzman commentedSomeone could be escaping earlier in their script.