I am writing a test outside of a Rails project, but ''require''-ing enough to use the ActiveRecord classes. It is connected to SQL Server 2005. It reads in XML and adds an ActiveRecord object like this : report = DvrStatusReport.new : report.x = y : report.save puts report.id This outputs a new id each time, but the record doesn''t appear in the the table according to the SQL Server Management Console. If I do similar in IRB, it does appear. Using the SQL Server profiler I see the line "IF @@TRANCOUNT > 0 COMMIT TRAN" for IRB, but not my test. If I add "report.connection.commit_db_transaction()" after report.save the record does appear. Although I never ask for transactions, it is turning on "implicit_transactions" in SQLServer (in my test and IRB), but somehow the commit is never happening. Thanks for any assistance. Regards, Gary -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Mr Magpie
2006-Sep-19 06:55 UTC
Re: SQLServer adapter fails to commit on save() (Gotcha !)
> Although I never ask for transactions, it is turning on > "implicit_transactions" in SQLServer (in my test and IRB), but somehow > the commit is never happening.I''ve answered my own question. The reason was "use_transactional_fixtures" in Test::Unit being set in test_helper.rb Gary -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---