-
Notifications
You must be signed in to change notification settings - Fork 548
Changing database in query options hash has no effect #437
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
Comments
This is intended behavior. |
Why? Changing the query_options (which is exposed, intentionally or not) and not actually using the options in the forthcoming query does not seem logical to me. Either I should not be allowed to modify the query_options directly or the query_options should be used in forthcoming queries, but the current behavior is deceptive. |
@gstaubli what version of mysql2 are you using? Each query should be using the options defined on the Mysql2::Client instance. So if you're changing that hash it seems like it should pickup the behavior. @sodabrew I'm probably missing something (it's halloween in GitHub HQ and I may or may not have had some beer before typing this), but it appears as though we're doing this already? Not sure why it's not being picked up. |
We copy all of the options into the query_options hash here: But the ones used for connecting are just these: Even upon reconnect, the original values are used because libmysql has them inside the client struct, we never pass the args back to mysql after that first connect. At one point I was working on a refactor that would remove the connection parameters from the query options hash, but wasn't sure if there would be fallout for people expecting them to be there. It'd have to be a 0.4.0 thing. |
Version: 0.3.13 While the client connection parameters (re: query_options hash) can be modified, mysql2 should not support on-the-fly modifications to it. Do I have that right? It sounds like this issue could be handled in at least three ways:
What is the reasoning for calling the client connection parameters hash "query_options," which implies the options pertain to the query and not the client? |
@sodabrew oh shit yeah totally missed that it happened to be the
This is sortof a legacy thing but mostly it's like this because I was being lazy a long time ago when I added this functionality. Hash#dup is way easier than trimming off the non-connection options for the |
@brianmario Separating connect_options and query_options is a desirable abstraction given the behavioral differences of client versus query-level options. |
Milestone 0.4.0, since it will change contents of accessible instance variables. |
Table:
Re-creating bug:
Workarounds to manipulating query_options hash
Using #select_db
Using options hash on client initialization
The text was updated successfully, but these errors were encountered: