Browse Source

batch with error in the middle test

Anton Lebedevich 12 years ago
parent
commit
58de903a2f
1 changed files with 12 additions and 0 deletions
  1. 12 0
      test_src/pgsql_tests.erl

+ 12 - 0
test_src/pgsql_tests.erl

@@ -159,6 +159,18 @@ execute_batch_test(Module) ->
                   Module:execute_batch(C, [{S1, [1]}, {S2, [1, 2]}])
                   Module:execute_batch(C, [{S1, [1]}, {S2, [1, 2]}])
       end).
       end).
 
 
+batch_error_test(Module) ->
+    with_rollback(
+      Module,
+      fun(C) ->
+              {ok, S} = Module:parse(C, "insert into test_table1(id, value) values($1, $2)"),
+              [{ok, 1}, {ok, 1}, {ok, 1}] =
+                  Module:execute_batch(C, [{S, [3, "batch_error 3"]},
+                                           {S, [2, "batch_error 2"]}, % duplicate key here
+                                           {S, [5, "batch_error 5"]}
+                                           ])
+      end).
+
 extended_select_test(Module) ->
 extended_select_test(Module) ->
     with_connection(
     with_connection(
       Module,
       Module,