From 25dbdc13a7480f7d0a17859928e6437a90bb876a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 6 Mar 2016 16:29:01 -0500 Subject: more step workarounds --- src/guff/database-updater.cr | 4 ++-- 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 @@ -75,6 +75,21 @@ module Guff 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, + ) + 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!!! -- cgit v1.2.3