Merge pull request #15 from jazzyb/master

fixes column types error
This commit is contained in:
Maas-Maarten Zeeman
2015-03-01 19:21:59 +01:00
2 changed files with 11 additions and 2 deletions

View File

@@ -587,8 +587,7 @@ do_column_types(ErlNifEnv *env, sqlite3_stmt *stmt)
for(i = 0; i < size; i++) {
type = sqlite3_column_decltype(stmt, i);
if(type == NULL) {
free(array);
return make_error_tuple(env, "sqlite3_malloc_failure");
type = "nil";
}
array[i] = make_atom(env, type);

View File

@@ -200,6 +200,16 @@ column_types_test() ->
ok.
nil_column_types_test() ->
{ok, Db} = esqlite3:open(":memory:"),
ok = esqlite3:exec("begin;", Db),
ok = esqlite3:exec("create table t1(c1 variant);", Db),
ok = esqlite3:exec("commit;", Db),
{ok, Stmt} = esqlite3:prepare("select c1 + 1, c1 from t1", Db),
{nil, variant} = esqlite3:column_types(Stmt),
ok.
reset_test() ->
{ok, Db} = esqlite3:open(":memory:"),