Multi-step exec support (#27)

This commit is contained in:
Tom Richards 2017-09-14 14:51:25 -04:00 committed by Brian J. Cardiff
parent c850ec4b72
commit e6d5ad33c3
2 changed files with 13 additions and 1 deletions

View File

@ -119,4 +119,12 @@ DB::DriverSpecs(DB::Any).run do
end
end
end
it "handles single-step pragma statements" do |db|
db.exec %(PRAGMA synchronous = OFF)
end
it "handles multi-step pragma statements" do |db|
db.exec %(PRAGMA journal_mode = memory)
end
end

View File

@ -19,7 +19,11 @@ class SQLite3::Statement < DB::Statement
end
# exec
step = LibSQLite3::Code.new LibSQLite3.step(self)
step = uninitialized LibSQLite3::Code
loop do
step = LibSQLite3::Code.new LibSQLite3.step(self)
break unless step == LibSQLite3::Code::ROW
end
raise Exception.new(sqlite3_connection) unless step == LibSQLite3::Code::DONE
rows_affected = LibSQLite3.changes(sqlite3_connection).to_i64