When running drush mongodb-cli or mongodb-query, "mongodb://" in the host breaks the shell.
eg:
drush mdbc
MongoDB shell version: 2.2.2
connecting to: mongodb://127.0.0.1/XXXX
Fri Mar 1 02:45:59 Assertion failure _setName.size() src/mongo/client/dbclientinterface.h 209
...
It looks like the PECL mongo client can handle the 'mongodb://' in the host, but works just as well without it (AFAICT); whereas the js shell client chokes on it and spits out a pretty unhelpful error message.
line 62 in the README.txt: 'host' => 'mongodb://USER:PASS@localhost',
At first I was thinking we could just remove the scheme from the host, but that looks necessary to support the user and pass authentication. So I've borrowed the relevant db url parsing code from drush's sitealias include for the upcoming patch which should work w/ or w/o the scheme and support user and pass in the mongo shell too.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | drush-mongo-shell-host-scheme-error-1930822.patch | 797 bytes | tloudon |
| #4 | mongodb-fix_drush_mdbc_command-1930822-4-D7.patch | 1.39 KB | Anonymous (not verified) |
Comments
Comment #1
tloudon commentedand here's the patch.
Comment #2
mcrittenden commentedComment #3
mwisner commentedThe patch provided in #1 resolved the issue for me.
Ubuntu 12.04 / Mongodb installed via pecl.
Comment #4
Anonymous (not verified) commentedThe patch from #1 works fine except for the fact that it drops the port number and that it ignores the cases when parse_url() returns FALSE.
Here is a patch that generates the proper database address syntax and arguments.
Comment #5
fgmPart of this has already been committed while working on #1823478: Drush command line commands should support connections to replica sets.
Marking this issue as duplicate since it is more recent, this patch should be merged with the one on #1823478 because the former doesn't address the case of replica sets, while the latter doesn't address the case of authenticated connections, but both target the same issue.
Comment #6
fgm