On Friday, April 27, 2012 9:23:13 AM UTC-7, Rodrigo Rosenfeld Rosas wrote:
>
> I can get the sandbox information through "Rails.application.sandbox?".
> Could you give an example on how to use this Sequel's "after_connect" hook
> to ensure it will be inside a transaction?
>
DB.pool.after_connect = proc do |conn|
DB.send(:add_transaction, conn, {})
DB.send(:begin_transaction, conn, {})
end
DB.disconnect # remove existing connections
Correct use would also check if there is a current after_connect proc and
call it as well if so. Sequel stores all connected databases in
Sequel::DATABASES, so you could iterate over that array to sandbox all
databases. That should fix both of the major issues with the Rails
approach.
Note that this is not fool proof:
DB << 'COMMIT'
> Even in single threaded code, JRuby often performs better.
>
>
> That was not the case in my experiments. Nokogiri was able to perform a
> single operation a little faster with Ruby 1.9.3 than with JRuby and it
> would probably finish my task on MRI 1.9.3 faster than JRuby if I was to
> use a single thread.
>
>
I said often, not always. Nokogiri on MRI uses libxml2, while on JRuby I
think it uses Xerces, so the internals are pretty different.
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/SYd4Fy2l7z4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.