aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-06 16:29:01 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-06 16:29:01 -0500
commit25dbdc13a7480f7d0a17859928e6437a90bb876a (patch)
treecd18727a5899de7c5caebcc7a0d635c6982cae79
parent7effc93a6f3da8ab7b37f274b2aac33bfd7ee4b1 (diff)
downloadold-guff-25dbdc13a7480f7d0a17859928e6437a90bb876a.tar.bz2
old-guff-25dbdc13a7480f7d0a17859928e6437a90bb876a.zip
more step workarounds
-rw-r--r--src/guff/database-updater.cr4
-rw-r--r--src/guff/database.cr15
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)