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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/mysql2/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Error < StandardError
REPLACEMENT_CHAR = '?'
ENCODE_OPTS = {:undef => :replace, :invalid => :replace, :replace => REPLACEMENT_CHAR}

attr_accessor :error_number, :sql_state
attr_accessor :error_number
attr_reader :sql_state
attr_writer :server_version

# Mysql gem compatibility
Expand All @@ -18,10 +19,8 @@ def initialize(msg, server_version=nil)
super(clean_message(msg))
end

if "".respond_to? :encode
def sql_state=(state)
@sql_state = state.encode(ENCODE_OPTS)
end
def sql_state=(state)
@sql_state = ''.respond_to?(:encode) ? state.encode(ENCODE_OPTS) : state
end

private
Expand Down