diff options
author | Jamis Buck <jamis@37signals.com> | 2007-01-13 21:09:22 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2007-01-13 21:09:22 +0000 |
commit | c89ab08e95116ac464bb3cd8612f46dfdf080be3 (patch) | |
tree | b9a1837f4cb681b234fee05e02052a5f213bce39 /lib/sqlite3/statement.rb | |
parent | d6c84ceba976741e7a038151967c0587b8f22a16 (diff) | |
download | third_party-sqlite3-ruby-c89ab08e95116ac464bb3cd8612f46dfdf080be3.tar.gz third_party-sqlite3-ruby-c89ab08e95116ac464bb3cd8612f46dfdf080be3.tar.xz third_party-sqlite3-ruby-c89ab08e95116ac464bb3cd8612f46dfdf080be3.zip |
reset the statement when binding new variables (thanks Mike Kusick, debian bug #405614)
Diffstat (limited to 'lib/sqlite3/statement.rb')
-rw-r--r-- | lib/sqlite3/statement.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/sqlite3/statement.rb b/lib/sqlite3/statement.rb index 54faf15..09f24d9 100644 --- a/lib/sqlite3/statement.rb +++ b/lib/sqlite3/statement.rb @@ -116,6 +116,7 @@ module SQLite3 # See also #bind_params. def bind_param( param, value ) must_be_open! + reset! if active? if Fixnum === param case value when Bignum then @@ -156,7 +157,7 @@ module SQLite3 # See also #bind_params, #execute!. def execute( *bind_vars ) must_be_open! - @driver.reset( @handle ) if @results + reset! if active? bind_params(*bind_vars) unless bind_vars.empty? @results = ResultSet.new( @db, self ) @@ -195,6 +196,19 @@ module SQLite3 rows end + # Resets the statement. This is typically done internally, though it might + # occassionally be necessary to manually reset the statement. + def reset!(clear_result=true) + @driver.reset(@handle) + @results = nil if clear_result + end + + # Returns true if the statement is currently active, meaning it has an + # open result set. + def active? + not @results.nil? + end + # Return an array of the column names for this statement. Note that this # may execute the statement in order to obtain the metadata; this makes it # a (potentially) expensive operation. |