Zach Dennis
2009-Apr-18 23:09 UTC
[rspec-users] DDL Rails 2.3 nested transactions causing problems in specs
On Fri, Apr 17, 2009 at 6:36 PM, john <eagerwombat at gmail.com> wrote:> Mysql::Error: You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use near > ''RELEASE SAVEPOINT active_record_1'' at line 1: RELEASE SAVEPOINT > active_record_1 > a rails ticket concerning this error which was marked > invalid:?https://rails.lighthouseapp.com/projects/8994/tickets/1925-mysqlerror-savepoint-active_record_1-does-not-exist-rollback-to-savepoint-active_record_1 > > another rails doc concerning > issue:?http://github.com/lifo/docrails/commit/0e6b9695aff6500ad48c4dd9ab61343d7090b030 > > Good grief!The issue seems to not be ActiveRecord, but limitations of MySQL. Elia Schito gave a good explanation IMO on the rails ticket.> > Apparently any nested transaction (ex. a create statement inside a test) > will fail if you''re using MySQL. > still fighting it. If you create an ActiveRecord object in one ''it'' block, > it''s still there in the next block ?!?Do you have transactional fixtures turned off? The following works fine with Rails 2.3.2: http://gist.github.com/97819 Can you provide more information about your problem? You didn''t really show us what you were doing, and what you thought was failing, and what you actually expected.> The only workaround I''ve found for the MySQL''s unsupported nested > transactions is the following: > > User.transaction do > ??user1 = User.create(:name => "Alice") > ??User.transaction(:requires_new => true) do > ?? ?user2 = User.create(:name => "Bob") > ?? end > end > This is actually emulated using save points because most databases do not > support nested transactions. Some databases (SQLite) don?t support either > save points or nested transactions, so in that case this works just like > Rails 2.2 where the inner transaction(s) have no effect and if there are any > exceptions the entire transaction is rolled back. > > > PLUGIN SOLUTIONS that DON''T fix spec issues: > http://svn.viney.net.nz/things/rails/plugins/savepoints/ > http://github.com/spint/savepoints/tree/master?(github version with added > support for oracle) > > > ?HELP, RSPEC COMMUNITY!!! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com