DDL Rails 2.3 nested transactions causing problems in specs

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!

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/
GitHub - spint/savepoints: This plugin adds support for savepoints to ActiveRecord, allowing nested transactions. (github version with
added
support for oracle)

HELP, RSPEC COMMUNITY!!!

On Fri, Apr 17, 2009 at 6:36 PM, john [email protected] wrote:

Good grief!
The issue seems to not be ActiveRecord, but limitations of MySQL.
Elia S. 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:

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
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Zach D.
http://www.continuousthinking.com