Add function to get the last insert rowid (#62)

* Add function to get the last insert rowid

* Update esqlite3.erl

Co-authored-by: Maas-Maarten Zeeman <mmzeeman@xs4all.nl>
This commit is contained in:
Joe Freeman
2022-01-03 17:05:27 +00:00
committed by GitHub
parent d77b1fa76c
commit 09a9c86097
4 changed files with 72 additions and 0 deletions

View File

@@ -31,6 +31,15 @@ get_autocommit_test() ->
true = esqlite3:get_autocommit(Db),
ok.
last_insert_rowid_test() ->
{ok, Db} = esqlite3:open(":memory:"),
ok = esqlite3:exec("CREATE TABLE test (id INTEGER PRIMARY KEY, val STRING);", Db),
ok = esqlite3:exec("INSERT INTO test (val) VALUES ('this is a test');", Db),
{ok, 1} = esqlite3:last_insert_rowid(Db),
ok = esqlite3:exec("INSERT INTO test (val) VALUES ('this is another test');", Db),
{ok, 2} = esqlite3:last_insert_rowid(Db),
ok.
update_hook_test() ->
{ok, Db} = esqlite3:open(":memory:"),
ok = esqlite3:set_update_hook(self(), Db),