@@ -199,29 +199,6 @@ defmodule MyXQLTest do
199199 )
200200 end
201201
202- test "query_many!/4 with text" , c do
203- assert [ % MyXQL.Result { rows: [ [ 1 ] ] } , % MyXQL.Result { rows: [ [ 2 ] ] } ] =
204- MyXQL . query_many! ( c . conn , "SELECT 1; SELECT 2" , [ ] , query_type: :text )
205-
206- assert [ % MyXQL.Result { rows: [ [ 1 ] ] } ] =
207- MyXQL . query_many! ( c . conn , "SELECT 1;" , [ ] , query_type: :text )
208-
209- assert [ % MyXQL.Result { num_rows: 0 , rows: nil } ] =
210- MyXQL . query_many! ( c . conn , "DROP TABLE IF EXISTS not_a_table;" , [ ] ,
211- query_type: :text
212- )
213-
214- assert [ % MyXQL.Result { num_rows: 0 , rows: nil } , % MyXQL.Result { rows: [ [ 1 ] ] } ] =
215- MyXQL . query_many! ( c . conn , "DROP TABLE IF EXISTS not_a_table; SELECT 1;" , [ ] ,
216- query_type: :text
217- )
218-
219- assert [ % MyXQL.Result { rows: [ [ 1 ] ] } , % MyXQL.Result { num_rows: 0 , rows: nil } ] =
220- MyXQL . query_many! ( c . conn , "SELECT 1; DROP TABLE IF EXISTS not_a_table;" , [ ] ,
221- query_type: :text
222- )
223- end
224-
225202 test "query_many/4 with text returning error" , c do
226203 assert { :error , % MyXQL.Error { mysql: % { code: 1064 } } } =
227204 MyXQL . query_many ( c . conn , "SELECT 1; BADCOMMAND;" , [ ] , query_type: :text )
@@ -666,9 +643,6 @@ defmodule MyXQLTest do
666643 assert % MyXQL.Result { rows: nil } =
667644 MyXQL . query! ( c . conn , "CALL single_ok_procedure()" , [ ] , query_type: :text )
668645
669- assert % MyXQL.Result { rows: nil } =
670- MyXQL . query! ( c . conn , "CALL single_ok_procedure()" , [ ] , query_type: :text )
671-
672646 assert [ % MyXQL.Result { rows: [ [ 1 ] ] } , % MyXQL.Result { num_rows: 0 , rows: nil } ] =
673647 MyXQL . query_many! ( c . conn , "CALL one_resultset_one_ok_procedure()" )
674648
@@ -694,8 +668,12 @@ defmodule MyXQLTest do
694668 % MyXQL.Result { num_rows: 0 , rows: nil }
695669 ] } = MyXQL . prepare_execute_many! ( c . conn , "" , "CALL multi_procedure()" )
696670
671+ assert % MyXQL.Query { } = query = MyXQL . prepare! ( c . conn , "" , "CALL single_ok_procedure()" )
672+
673+ assert % MyXQL.Result { rows: nil } = MyXQL . execute! ( c . conn , query )
674+
697675 assert % MyXQL.Queries { } =
698- query = MyXQL . prepare_many! ( c . conn , "" , "CALL one_resultset_one_ok_procedure()" )
676+ query = MyXQL . prepare_many! ( c . conn , "" , "CALL one_resultset_one_ok_procedure()" )
699677
700678 assert [ % MyXQL.Result { rows: [ [ 1 ] ] } , % MyXQL.Result { num_rows: 0 , rows: nil } ] =
701679 MyXQL . execute_many! ( c . conn , query )
@@ -709,10 +687,10 @@ defmodule MyXQLTest do
709687 ] = MyXQL . execute_many! ( c . conn , query )
710688 end
711689
712- test "stream procedure with multiple results " , c do
690+ test "stream stored procedure " , c do
713691 statement = "CALL one_resultset_one_ok_procedure()"
714692
715- assert_raise RuntimeError , ~r" returning multiple results is not supported" , fn ->
693+ assert_raise RuntimeError , ~r" streaming stored procedures is not supported" , fn ->
716694 MyXQL . transaction ( c . conn , fn conn ->
717695 stream = MyXQL . stream ( conn , statement , [ ] , max_rows: 2 )
718696 Enum . to_list ( stream )
@@ -793,6 +771,17 @@ defmodule MyXQLTest do
793771 assert % MyXQL.Queries { } = query = MyXQL . prepare_many! ( c . conn , "" , "CALL multi_procedure()" )
794772 assert :ok == MyXQL . close ( c . conn , query )
795773 end
774+
775+ test "using stream/4 with a multiple result query that is not a stored procedure" , c do
776+ statement = "SELECT 1; SELECT 2;"
777+
778+ assert_raise MyXQL.Error , ~r" \( 1064\) " , fn ->
779+ MyXQL . transaction ( c . conn , fn conn ->
780+ stream = MyXQL . stream ( conn , statement , [ ] , max_rows: 2 )
781+ Enum . to_list ( stream )
782+ end )
783+ end
784+ end
796785 end
797786
798787 @ tag :skip
0 commit comments