From 98fbeb6f64e562e9889346d46737ad2d5d5cf6fe Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Wed, 1 Sep 2010 11:42:16 -0700 Subject: [PATCH] add aliases for Mysql compatibility --- lib/mysql2/error.rb | 4 ++++ spec/mysql2/error_spec.rb | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/mysql2/error.rb b/lib/mysql2/error.rb index c14ae358c..e195c2cbb 100644 --- a/lib/mysql2/error.rb +++ b/lib/mysql2/error.rb @@ -7,5 +7,9 @@ def initialize msg @error_number = nil @sql_state = nil end + + # Mysql gem compatibility + alias_method :errno, :error_number + alias_method :error, :message end end diff --git a/spec/mysql2/error_spec.rb b/spec/mysql2/error_spec.rb index f321003ea..969074448 100644 --- a/spec/mysql2/error_spec.rb +++ b/spec/mysql2/error_spec.rb @@ -13,4 +13,13 @@ it "should respond to #sql_state" do @error.should respond_to(:sql_state) end + + # Mysql gem compatibility + it "should alias #error_number to #errno" do + @error.should respond_to(:errno) + end + + it "should alias #message to #error" do + @error.should respond_to(:error) + end end