Forum: RSpec DDL Rails 2.3 nested transactions causing problems in specs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7bd61e2deabb4063cc421c767e2d8d65?d=identicon&s=25 john (Guest)
on 2009-04-18 00:37
(Received via mailing list)
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/tick...

another rails doc concerning issue:
http://github.com/lifo/docrails/commit/0e6b9695aff...

Good grief!


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 ?!?

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!!!
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2009-04-19 01:16
(Received via mailing list)
On Fri, Apr 17, 2009 at 6:36 PM, john <eagerwombat@gmail.com> wrote:
> 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.

> support nested transactions. Some databases (SQLite) don’t support either
>
>  HELP, RSPEC COMMUNITY!!!
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
This topic is locked and can not be replied to.