diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-06 11:25:27 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-06 11:25:27 -0500 |
commit | 314ee50c5c52b75b6becbc0f0988429a6503732e (patch) | |
tree | cb28a7cf8b3a6c81e0935fb2796f41b243abc056 /src/guff | |
parent | 08f6d17f91a7c990c8ada20c4038db067ac4874d (diff) | |
download | old-guff-314ee50c5c52b75b6becbc0f0988429a6503732e.tar.bz2 old-guff-314ee50c5c52b75b6becbc0f0988429a6503732e.zip |
s/bind/run/
Diffstat (limited to 'src/guff')
-rw-r--r-- | src/guff/database-updater.cr | 2 | ||||
-rw-r--r-- | src/guff/database.cr | 63 |
2 files changed, 15 insertions, 50 deletions
diff --git a/src/guff/database-updater.cr b/src/guff/database-updater.cr index e06aff3..9a7bf97 100644 --- a/src/guff/database-updater.cr +++ b/src/guff/database-updater.cr @@ -25,7 +25,7 @@ module Guff CREATE TABLE metadata ( name TEXT PRIMARY KEY, value TEXT NOT NULL - ) + ); }, %{ INSERT INTO metadata(name, value) VALUES ('version', '1') }, %{ diff --git a/src/guff/database.cr b/src/guff/database.cr index cabc91c..e94a085 100644 --- a/src/guff/database.cr +++ b/src/guff/database.cr @@ -23,7 +23,7 @@ module Guff ) r = nil - bind(sql).execute do |rs| + run(sql).execute do |rs| if rs.next # FIXME r = rs[0] @@ -36,28 +36,11 @@ module Guff def one( sql : String, - args : Array(String) + args : Array(String) | Hash(String, String) ) r = nil - bind(sql, args).execute do |rs| - if rs.next - # FIXME - r = rs[0] - end - end - - # return result - r - end - - def one( - sql : String, - args : Hash(String, String), - ) - r = nil - - bind(sql, args).execute do |rs| + run(sql, args).execute do |rs| if rs.next # FIXME r = rs[0] @@ -72,24 +55,7 @@ module Guff r = nil # exec query - bind(sql).execute do |rs| - if rs.next - r = to_row(rs) - end - end - - # return result - r - end - - def row( - sql : String, - args : Array(String) - ) - r = nil - - # exec query - bind(sql, args).execute do |rs| + run(sql).execute do |rs| if rs.next r = to_row(rs) end @@ -101,12 +67,12 @@ module Guff def row( sql : String, - args : Hash(String, String) + args : Array(String) | Hash(String, String) ) r = nil # exec query - bind(sql, args).execute do |rs| + run(sql, args).execute do |rs| if rs.next r = to_row(rs) end @@ -118,11 +84,9 @@ module Guff def all( sql : String, - args : Array(String), &block : Proc(Hash(String, ::SQLite3::Value), Nil) \ ) - # build statement - bind(sql, args).execute do |rs| + run(sql).execute do |rs| # walk results while rs.next # build row and pass it to callback @@ -130,15 +94,17 @@ module Guff end end + # close statement, return nil nil end def all( sql : String, - args : Hash(String, String), + args : Array(String) | Hash(String, String), &block : Proc(Hash(String, ::SQLite3::Value), Nil) \ ) - bind(sql, args).execute do |rs| + # build statement + run(sql, args).execute do |rs| # walk results while rs.next # build row and pass it to callback @@ -146,7 +112,6 @@ module Guff end end - # close statement, return nil nil end @@ -156,12 +121,12 @@ module Guff query("COMMIT") end - private def bind(sql : String) + private def run(sql : String) # build statement prepare(sql) end - private def bind( + private def run( sql : String, args : Array(String)? ) @@ -179,7 +144,7 @@ module Guff st end - private def bind( + private def run( sql : String, args : Hash(String, String)? ) |