diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a77690f960..91685d1692 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,7 +117,7 @@ jobs: - name: Test v tutorials run: | cd tutorials/code/blog - v . + ../../../v . # Alpine docker pre-built container diff --git a/tutorials/code/blog/blog.v b/tutorials/code/blog/blog.v index d6d4355b39..75fc08cf5f 100644 --- a/tutorials/code/blog/blog.v +++ b/tutorials/code/blog/blog.v @@ -7,6 +7,7 @@ import json struct App { vweb.Context +mut: db sqlite.DB } @@ -31,8 +32,12 @@ pub fn (app &App) index() vweb.Result { } pub fn (mut app App) init_once() { - db := sqlite.connect('blog.db') or { panic(err) } - app.db = db + app.db = sqlite.connect('blog.db') or { panic(err) } + app.db.exec('create table if not exists article (' + + 'id integer primary key, ' + + "title text default ''," + + "text text default ''" + + ');') } pub fn (mut app App) init() { @@ -42,6 +47,8 @@ pub fn (mut app App) new() vweb.Result { return $vweb.html() } +[post] +['/new_article'] pub fn (mut app App) new_article() vweb.Result { title := app.form['title'] text := app.form['text'] @@ -53,6 +60,7 @@ pub fn (mut app App) new_article() vweb.Result { title: title text: text } + println('posting article') println(article) sql app.db { insert article into Article diff --git a/vlib/sqlite/sqlite.v b/vlib/sqlite/sqlite.v index 3c74795b8d..cdededad73 100644 --- a/vlib/sqlite/sqlite.v +++ b/vlib/sqlite/sqlite.v @@ -150,7 +150,6 @@ pub fn (db DB) exec(query string) ([]Row, int) { } rows << row } - C.sqlite3_finalize(stmt) return rows, res }