Skip to content

default_file option is ignored if added to Client.default_query_options #493

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

Open
fcrimins opened this issue Mar 4, 2014 · 5 comments
Open
Milestone

Comments

@fcrimins
Copy link

fcrimins commented Mar 4, 2014

This can be fixed by using the '@query_options' hash rather than the 'opts' hash in the options/symbols loop following 'initialize_ext' in Client#initialize.

Presumably this problem exists for other options if they are specified in Client.default_query_options as well.

@sodabrew
Copy link
Collaborator

sodabrew commented Mar 4, 2014

The README shows how to set the flag in the connect options hash. default_file is not a query option. That said, we probably should split out the default connection options from the query options.

@fcrimins
Copy link
Author

fcrimins commented Mar 4, 2014

Yes, it works correctly if you set it in the connect options hash. It
doesn't work if you set it in the default_query_options hash.

See "Cascading configs" section of
http://rubydoc.info/gems/mysql2/0.2.3/frames

these are the defaults all Mysql2::Client instances

inheritMysql2::Client.default_query_options.merge!(:as => :array)

On Tue, Mar 4, 2014 at 5:33 PM, Aaron Stone [email protected]:

The README shows how to set the flag in the connect options hash.
default_file is not a query option.

Reply to this email directly or view it on GitHubhttps://github.com//issues/493#issuecomment-36687269
.

@sodabrew
Copy link
Collaborator

sodabrew commented Mar 4, 2014

Is there a fix that you would like to see here, either to the docs or the code?

@fcrimins
Copy link
Author

fcrimins commented Mar 4, 2014

Is there a way to set a default_file to be used for all connections and all
queries? Perhaps I'm missing this.

I added this line "opts = @query_options" after "@query_options.merge!
opts" (in Client#initialize) in my version and now I can set username and
hostname in a SQL .cnf file that I only have to specify once. FWIW, I'm
also specifying database name (another input required by 'connect') in this
hash as well. I would think that any options required by 'connect' would
be specifiable in this manner.

On Tue, Mar 4, 2014 at 6:20 PM, Aaron Stone [email protected]:

Is there a fix that you would like to see here, either to the docs or the
code?

Reply to this email directly or view it on GitHubhttps://github.com//issues/493#issuecomment-36691815
.

@sodabrew
Copy link
Collaborator

sodabrew commented Mar 4, 2014

I do not recommend using this method of configuring future instances of Mysql2::Client. Keep your own hash of connection options and use it when you create a connection instance.

@sodabrew sodabrew added this to the 0.4.0 milestone Jul 29, 2014
@sodabrew sodabrew modified the milestones: 0.4.0, 0.5.0 Aug 5, 2015
@sodabrew sodabrew modified the milestones: 0.5.0, 0.6.0 Mar 19, 2018
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

2 participants