Skip to content

change sql_state to attr_reader to avoid ruby warning #544

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

Merged
merged 1 commit into from
Sep 20, 2014

Conversation

seuros
Copy link
Contributor

@seuros seuros commented Sep 13, 2014

this patch will remove this warning

mysql2-0.3.16/lib/mysql2/error.rb:22: warning: method redefined; discarding old sql_state=

@sodabrew
Copy link
Collaborator

Oh, interesting issue. I always took attr_reader as a hint that the value was read-only. I hope there aren't implementations of Ruby that take it to mean that way and get upset about the writer method?

@seuros
Copy link
Contributor Author

seuros commented Sep 13, 2014

attr_reader just define the getter , attr_writer define the setter, and attr_accesor define both.

@simi
Copy link
Contributor

simi commented Sep 14, 2014

What's your used Ruby implementation, version and are you using any of those options?

  -v, --verbose   print version number, then turn on verbose mode
  -w              turn warnings on for your script
  -W[level=2]     set warning level; 0=silence, 1=medium, 2=verbose

@seuros
Copy link
Contributor Author

seuros commented Sep 14, 2014

Any ruby implementation . https://travis-ci.org/rails/rails/jobs/35231944
I was thinking in changing the error class implementation like #545, but that will be a breaking change which nobody want for now.

@simi
Copy link
Contributor

simi commented Sep 14, 2014

Ahh, you mean this:

/home/travis/.rvm/rubies/ruby-1.9.3-p547/bin/ruby -w -Itest test/cases/disconnected_test.rb
/home/travis/.rvm/gems/ruby-1.9.3-p547/gems/bundler-1.7.2/lib/bundler/definition.rb:391: warning: private attribute?
/home/travis/.rvm/gems/ruby-1.9.3-p547/gems/bundler-1.7.2/lib/bundler/index.rb:110: warning: `*' interpreted as argument prefix
/home/travis/build/rails/rails/vendor/bundle/ruby/1.9.1/gems/minitest-5.3.3/lib/minitest.rb:46: warning: (...) interpreted as grouped expression
Using mysql2
/home/travis/build/rails/rails/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.16/lib/mysql2/error.rb:22: warning: method redefined; discarding old sql_state=
Run options: --seed 13616

ruby -w

@simi
Copy link
Contributor

simi commented Sep 14, 2014

The question is: Should be mysql2 warning proof?

@brianmario @sodabrew

@seuros
Copy link
Contributor Author

seuros commented Sep 14, 2014

@simi , Why it shouldn't ?

@sodabrew
Copy link
Collaborator

As much as possible, IMHO. Warnings are usually there for a reason.

@seuros I don't think #545 is a problematic change, because the arguments are very new. server_version was added in 271ea5e in January 2014 for version 0.3.15.

@seuros
Copy link
Contributor Author

seuros commented Sep 14, 2014

I don't know, when i changed it some of the gems i monitor broke. I don't remember which one, but i had the exact implementation.

sodabrew added a commit that referenced this pull request Sep 20, 2014
change sql_state to attr_reader to avoid ruby warning
@sodabrew sodabrew merged commit 8e46e5c into brianmario:master Sep 20, 2014
@sodabrew sodabrew added this to the 0.3.17 milestone Sep 20, 2014
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

Successfully merging this pull request may close these issues.

3 participants