Add esqlite3:changes/3 function to get nr of affected rows

This commit is contained in:
Arjan Scherpenisse
2014-06-15 00:14:11 +02:00
parent 3847315586
commit 476c34e1e3
4 changed files with 78 additions and 1 deletions

View File

@@ -25,11 +25,20 @@ simple_query_test() ->
ok = esqlite3:exec("begin;", Db),
ok = esqlite3:exec("create table test_table(one varchar(10), two int);", Db),
ok = esqlite3:exec(["insert into test_table values(", "\"hello1\"", ",", "10" ");"], Db),
{ok, 1} = esqlite3:changes(Db),
ok = esqlite3:exec(["insert into test_table values(", "\"hello2\"", ",", "11" ");"], Db),
{ok, 1} = esqlite3:changes(Db),
ok = esqlite3:exec(["insert into test_table values(", "\"hello3\"", ",", "12" ");"], Db),
{ok, 1} = esqlite3:changes(Db),
ok = esqlite3:exec(["insert into test_table values(", "\"hello4\"", ",", "13" ");"], Db),
{ok, 1} = esqlite3:changes(Db),
ok = esqlite3:exec("commit;", Db),
ok = esqlite3:exec("select * from test_table;", Db),
ok = esqlite3:exec("delete from test_table;", Db),
{ok, 4} = esqlite3:changes(Db),
ok.
prepare_test() ->
@@ -39,6 +48,7 @@ prepare_test() ->
{ok, Statement} = esqlite3:prepare("insert into test_table values(\"one\", 2)", Db),
'$done' = esqlite3:step(Statement),
{ok, 1} = esqlite3:changes(Db),
ok = esqlite3:exec(["insert into test_table values(", "\"hello4\"", ",", "13" ");"], Db),