Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

in raw mode, store last result inside connection

  • Loading branch information...
commit 7ffe57ac41ffb023de1059fd2693f0ef0c3de3e0 1 parent 2120ea6
@tmm1 authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/em/mysql.rb
View
10 lib/em/mysql.rb
@@ -2,6 +2,12 @@
require 'eventmachine'
require 'mysqlplus'
+class Mysql
+ def result
+ @cur_result
+ end
+end
+
class EventedMysql < EM::Connection
def initialize mysql, opts
@mysql = mysql
@@ -35,6 +41,8 @@ def notify_readable
log 'mysql response', Time.now-start, sql
arg = case response
when :raw
+ result = @mysql.get_result
+ @mysql.instance_variable_set('@cur_result', result)
@mysql
when :select
ret = []
@@ -350,7 +358,7 @@ def self.connection_pool
should 'have raw mode which yields the mysql object' do
@mysql.execute('select 1+2 as num', :raw){ |mysql|
mysql.should.is_a? Mysql
- mysql.get_result.all_hashes.should == [{'num' => '3'}]
+ mysql.result.all_hashes.should == [{'num' => '3'}]
done
}
end
Please sign in to comment.
Something went wrong with that request. Please try again.