diff --git a/spec/db_spec.cr b/spec/db_spec.cr index 658525c..ff508f6 100644 --- a/spec/db_spec.cr +++ b/spec/db_spec.cr @@ -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 diff --git a/src/sqlite3/statement.cr b/src/sqlite3/statement.cr index 90c4d7e..510da04 100644 --- a/src/sqlite3/statement.cr +++ b/src/sqlite3/statement.cr @@ -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