File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -614,6 +614,21 @@ def connect *args
614
614
615
615
@multi_client . more_results? . should be_false
616
616
end
617
+
618
+ it "#more_results? should work with stored procedures" do
619
+ @multi_client . query ( "DROP PROCEDURE IF EXISTS test_proc" )
620
+ @multi_client . query ( "CREATE PROCEDURE test_proc() BEGIN SELECT 1 AS 'set_1'; SELECT 2 AS 'set_2'; END" )
621
+ @multi_client . query ( "CALL test_proc()" ) . first . should eql ( { 'set_1' => 1 } )
622
+ @multi_client . more_results? . should be_true
623
+
624
+ @multi_client . next_result
625
+ @multi_client . store_result . first . should eql ( { 'set_2' => 2 } )
626
+
627
+ @multi_client . next_result
628
+ @multi_client . store_result . should be_nil # this is the result from CALL itself
629
+
630
+ @multi_client . more_results? . should be_false
631
+ end
617
632
end
618
633
end
619
634
Original file line number Diff line number Diff line change 107
107
108
108
context "streaming" do
109
109
it "should maintain a count while streaming" do
110
- result = @client . query ( 'SELECT 1' )
111
-
112
- result . count . should eql ( 1 )
110
+ result = @client . query ( 'SELECT 1' , :stream => true , :cache_rows => false )
111
+ result . count . should eql ( 0 )
113
112
result . each . to_a
114
113
result . count . should eql ( 1 )
115
114
end
116
115
117
- it "should set the actual count of rows after streaming " do
118
- result = @client . query ( "SELECT * FROM mysql2_test " , :stream => true , :cache_rows => false )
116
+ it "should retain the count when mixing first and each " do
117
+ result = @client . query ( "SELECT 1 UNION SELECT 2 " , :stream => true , :cache_rows => false )
119
118
result . count . should eql ( 0 )
120
- result . each { | r | }
119
+ result . first
121
120
result . count . should eql ( 1 )
121
+ result . each . to_a
122
+ result . count . should eql ( 2 )
122
123
end
123
124
124
125
it "should not yield nil at the end of streaming" do
You can’t perform that action at this time.
0 commit comments