I started developing my rails application using sqlite. I have reached a point where I need to make sure that some code runs under a database transaction which is something new for me. To begin the journey, I wan't to see the transactions being used in every test case. After all, I'll need to disable them for testing this feature.
When I see the test.log for any one of my specs, I get something like this in test.log
:
SQL (0.2ms) SELECT 1 FROM "users" WHERE ("users"."login" = 'jaimito1') LIMIT 1
SQL (0.2ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
AREL (0.5ms) INSERT INTO "users" ("login", "password_digest", "created_at", "updated_at") VALUES ('jaimito1', '$2a$10$lJ/qIMfKymDmKuY6fYQF.u3bg8/ZdIzGU04MsjC6vJk8qygMEiemC', '2011-07-31 21:32:05.886797', '2011-07-31 21:32:05.886797')
No sign of any transaction even though I have config.use_transactional_fixtures = true
in my spec_helper.rb
If change my database to MySQL, the same test produces this output in test.log
:
SQL (0.2ms) BEGIN
SQL (0.2ms) SAVEPOINT active_record_1
SQL (0.3ms) SELECT 1 FROM `users` WHERE (`users`.`login` = BINARY 'jaimito1') LIMIT 1
SQL (5.9ms) SHOW TABLES
SQL (1.2ms) describe `users`
AREL (0.3ms) INSERT INTO `users` (`login`, `password_digest`, `created_at`, `updated_at`) VALUES ('jaimito1', '$2a$10$Ujsv0XGRLyHBZsI7sY4Vf.jv3bm1fyfeueV79o91gDY9xbdc7KUGC', '2011-07-31 19:50:28', '2011-07-31 19:50:28')
SQL (0.1ms) RELEASE SAVEPOINT active_record_1
SQL (0.7ms) ROLLBACK
So? What is going on here? Why are the transactions not shown for sqlite? My understanding is that sqlite transactions are supported in rails.
My versions: Mac OS X 10.6.8, Rails 3.0.9, sqlite 3.7.6, sqlite3 gem 1.3.3, ruby 1.9.2p290, mysql 5.0.91