Em 26-04-2012 15:18, Jeremy Evans escreveu:
On Thursday, April 26, 2012 10:55:13 AM UTC-7, Rodrigo Rosenfeld Rosas wrote:

    Yes, I know but I don't have any control over any of those APIs
    (Sequel, Rails and RSpec). I just know this is a limitation of
    Sequel that won't allow me to use transactions in situations I
    can't handle them using blocks.

    I can't rewrite every single software because they were not
    intended to work with the Sequel way of dealing with transactions.

    I hope you understand what I mean.


I understand what you mean. This isn't a limitation in Sequel. As I've shown, the capability exists. It's a deliberate choice not to provide a public API.

Your only real problem is with RSpec...

Actually I've learned about the sandbox version of the console today and I found it very interesting. It would be great to be able to use it with Sequel too.

I don't think every block-based API should provide an alternative API, but I don't see any issues in being able to manipulate connections and transactions directly through a public API:

conn = DB.pool.pop
conn.start_transaction
# then in other context that has a reference to conn:
conn.rollback_transaction # or conn.commit_transaction
conn.release

It is up to the developer using such API to be sure connections won't leak.

This works like the File.open API:

f = File.open(filename, 'w')
# f << ...
f.close

File.open(filename, 'w') do |f|
# f << ...
end

I'm pretty sure most block-based API (threads, sockets, etc) provide an alternative to the block-based approach.

Why should it be different with Sequel?

Best,
Rodrigo.

--
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
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.

Reply via email to