We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0bb8b75 commit 254d6fdCopy full SHA for 254d6fd
lib/sqlite3/database.rb
@@ -94,7 +94,7 @@ def prepare sql
94
begin
95
yield stmt
96
ensure
97
- stmt.close
+ stmt.close unless stmt.closed?
98
end
99
100
test/test_database.rb
@@ -107,6 +107,15 @@ def test_prepare
107
assert_instance_of(SQLite3::Statement, stmt)
108
109
110
+ def test_block_prepare_does_not_double_close
111
+ db = SQLite3::Database.new(':memory:')
112
+ r = db.prepare('select "hello world"') do |stmt|
113
+ stmt.close
114
+ :foo
115
+ end
116
+ assert_equal :foo, r
117
118
+
119
def test_total_changes
120
db = SQLite3::Database.new(':memory:')
121
db.execute("create table foo ( a integer primary key, b text )")
0 commit comments