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
Connect to DB whose name consists entirely of numerics #425
Connect to DB whose name consists entirely of numerics #425
Conversation
We should just go ahead and do this for |
+1 nice work @BanzaiMan – I was just about to say what @brianmario said – please add .to_s on the other stringy options. |
Would you mind adding a test to make sure you can pass integers for these values now? |
@brianmario Not at all. I'll work on the tests tonight. Thanks. |
Please advise if the spec setup (d8aaac9) can be improved. |
By the way, |
Oh, that's a really good point. Most of those value could be nil. We sort of want a ".to_s_or_nil" function. |
This is super ugly, but how about (edited - let's use your latter suggestion instead):
|
That'll work On Fri, Oct 4, 2013 at 11:43 AM, Aaron Stone notifications@github.comwrote:
|
I haven't tested it, so I'll simply ask: can https://github.com/brianmario/mysql2/blob/926d579/ext/mysql2/client.c#L289 gives me a pause. |
Nope, port must be an integer: http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html |
@sodabrew Oh, I see. You used |
Awesome, I'll close this and merge #427. Thanks for the tests and the initial fix @BanzaiMan! |
@BanzaiMan I realized the more obvious solution to the underlying issue a few days late. With YAML, you simply have to quote numbers to prevent it from being cast to a numeric type, e.g.: production:
username: "12345"
password: "67890" I'm skeptical of whether it is right to support this: If the code can be simply changed as: Not sure if I would propose reverting the change; consistency with other db drivers (like pg, as you noted) is somewhat nice. |
Indeed, that is a workaround for the issue that led me to this issue in the first place. I opened this issue precisely for the parity with |
If the database name one wishes to connect to has only numeric, then the attempt fails with:
A similar database works fine with the
pg
gem (configured viaconfig/database.yml
for a Rails app), so it might be a good idea to allow it.