i use rails transaction like these:
Account.transaction do
first.do_something
end
in first.do_something, i set a error, it should be rollback after these
code excuted
here is a param in my log:
[4;36;1mSQL (0.000000) [0;1mROLLBACK
i find rails do rollback operation, but in my database ,the data is not
rollback,
anybody may help?
--
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
I *think* this is the deal: the default table type in MySQL is MyISAM,
which is generally good for speed with web apps and such, but it does
not support transactions. So MySQL will take the rollback command, but
won''t actually roll anything back.
To enable transactions, you must be working with an InnoDB table, which
is the more hardcore table type in MySQL. It requires more resources to
read and write these tables, but according to databasejournal.com, you
get these benefits:
InnoDB Features
* ACID-compliant transactions.
* Full referential integrity
* Row-level locking
* Tables are stored in a tablespace (unlike MyISAM tables where each
table is a file)
Jason
Vincent Tsao wrote:> i use rails transaction like these:
>
> Account.transaction do
> first.do_something
> end
>
> in first.do_something, i set a error, it should be rollback after these
> code excuted
> here is a param in my log:
>
> [4;36;1mSQL (0.000000) [0;1mROLLBACK
>
> i find rails do rollback operation, but in my database ,the data is not
> rollback,
> anybody may help?
>
>
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
I try your suggestion ,set my table type as InnoDB, but still not rollback. there is something like config i miss? -- 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 -~----------~----~----~----~------~----~------~--~---