diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/guff/database-updater.cr | 4 | ||||
-rw-r--r-- | src/guff/database.cr | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/guff/database-updater.cr b/src/guff/database-updater.cr index b7a8af6..a6e2167 100644 --- a/src/guff/database-updater.cr +++ b/src/guff/database-updater.cr @@ -12,7 +12,7 @@ module Guff ", set_version_delete: " - DELETE FROM metadata where name = 'version' + DELETE FROM metadata WHERE name = 'version' ", set_version_insert: " @@ -138,7 +138,7 @@ module Guff private def set_version(version) @db.query(SQL[:set_version_delete]) - @db.query(SQL[:set_version_insert], [version]) + @db.query(SQL[:set_version_insert], [version.to_s]) end end end diff --git a/src/guff/database.cr b/src/guff/database.cr index 67a7a1a..5b971b6 100644 --- a/src/guff/database.cr +++ b/src/guff/database.cr @@ -82,6 +82,21 @@ module Guff def query( sql : String, args = nil : Array(String) | Hash(String, String) | Nil, + ) + run(sql, args) do |rs| + # make sure query executes + rs.next + nil + end + end + + # + # NOTE: if you pass a block, be sure to call rs.next at least once, + # or the query will _not_ execute!!! + # + def query( + sql : String, + args = nil : Array(String) | Hash(String, String) | Nil, &block : Proc(::SQLite3::ResultSet, Nil) \ ) run(sql, args, &block) |